Skip to content

Commit 4c16c86

Browse files
committed
Return callback status from wait()
1 parent 0be8320 commit 4c16c86

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sounddevice.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def callback(outdata, frames, time, status):
282282
ctx.callback_exit()
283283

284284
ctx.start_stream(OutputStream, samplerate, ctx.output_channels,
285-
ctx.output_dtype, callback, blocking, **kwargs)
285+
ctx.output_dtype, callback, blocking,
286+
prime_output_buffers_using_stream_callback=False,
287+
**kwargs)
286288

287289

288290
def rec(frames=None, samplerate=None, channels=None, dtype=None,
@@ -432,10 +434,16 @@ def wait():
432434
433435
Playback/recording can be stopped with a :class:`KeyboardInterrupt`.
434436
437+
Returns
438+
-------
439+
CallbackFlags or None
440+
If at least one buffer over-/underrun happened during the last
441+
playback/recording, a :class:`CallbackFlags` object is returned.
442+
435443
"""
436444
global _last_callback
437445
if _last_callback:
438-
_last_callback.wait()
446+
return _last_callback.wait()
439447

440448

441449
def stop(ignore_errors=True):
@@ -2207,6 +2215,7 @@ def wait(self):
22072215
self.event.wait()
22082216
finally:
22092217
self.stream.close()
2218+
return self.status if self.status else None
22102219

22112220

22122221
def _check_mapping(mapping, channels):

0 commit comments

Comments
 (0)