File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,18 @@ class from the standard library can be used.
7676 :param size: The number of elements in the buffer (must be a
7777 power of 2).
7878 :type size: int
79+ :param buffer: optional pre-allocated buffer to use with RingBuffer
80+ :type buffer: buffer
7981
8082 """
8183
82- def __init__ (self , elementsize , size ):
84+ def __init__ (self , elementsize , size , buffer = None ):
8385 self ._ptr = self ._ffi .new ('PaUtilRingBuffer*' )
84- self ._data = self ._ffi .new ('unsigned char[]' , size * elementsize )
86+ if buffer is None :
87+ self ._data = self ._ffi .new ('unsigned char[]' , size * elementsize )
88+ else :
89+ self ._data = self ._ffi .from_buffer (buffer )
90+
8591 res = self ._lib .PaUtil_InitializeRingBuffer (
8692 self ._ptr , elementsize , size , self ._data )
8793 if res != 0 :
You can’t perform that action at this time.
0 commit comments