Skip to content

Commit 2b2ecdd

Browse files
Fix callback handling and flag initialization
1 parent 715d988 commit 2b2ecdd

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/sounddevice.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ class CallbackFlags:
19271927
__slots__ = '_flags'
19281928

19291929
def __init__(self, flags=0x0):
1930-
self._flags = flags
1930+
self._flags = int(flags)
19311931

19321932
def __repr__(self):
19331933
flags = str(self)
@@ -2770,18 +2770,18 @@ def _get_stream_parameters(kind, device, channels, dtype, latency,
27702770
return parameters, dtype, samplesize, samplerate
27712771

27722772

2773-
def _wrap_callback(callback, *args):
2773+
def _wrap_callback(callback, data, frames, time, status):
27742774
"""Invoke callback function and check for custom exceptions."""
2775-
args = args[:-1] + (CallbackFlags(args[-1]),)
2775+
cf = CallbackFlags.__new__(CallbackFlags)
2776+
cf._flags = int(status)
27762777
try:
2777-
callback(*args)
2778+
callback(data, frames, time, cf)
27782779
except CallbackStop:
27792780
return _lib.paComplete
27802781
except CallbackAbort:
27812782
return _lib.paAbort
27822783
return _lib.paContinue
27832784

2784-
27852785
def _buffer(ptr, frames, channels, samplesize):
27862786
"""Create a buffer object from a pointer to some memory."""
27872787
return _ffi.buffer(ptr, frames * channels * samplesize)

0 commit comments

Comments
 (0)