Skip to content

Commit 4d52471

Browse files
riggsdmgeier
authored andcommitted
Add get_stream() function for accessing the current stream (#70)
1 parent b780a2f commit 4d52471

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

sounddevice.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,26 @@ def get_status():
587587
raise RuntimeError('play()/rec()/playrec() was not called yet')
588588

589589

590+
def get_stream():
591+
"""Get a reference to the current stream.
592+
593+
This applies only to streams created by calls to `play()`, `rec()`,
594+
or `playrec()`.
595+
596+
Returns
597+
-------
598+
Stream
599+
An `OutputStream`, `InputStream`, or `Stream` associated with
600+
the last invocation of `play()`, `rec()` or `playrec()`
601+
respectively.
602+
603+
"""
604+
if _last_callback:
605+
return _last_callback.stream
606+
else:
607+
raise RuntimeError('play()/rec()/playrec() was not called yet')
608+
609+
590610
def query_devices(device=None, kind=None):
591611
"""Return information about available devices.
592612

0 commit comments

Comments
 (0)