summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid A. Riggs <david.a.riggs@gmail.com>2017-01-26 11:21:00 -0800
committerMatthias Geier <Matthias.Geier@gmail.com>2017-01-26 20:21:00 +0100
commit4d524714a9bc0eef8fa880bc58594bd5792cd6dc (patch)
tree7f54652f280899d7c0c7ca219c1b2a0c28d9234a
parentb780a2fcb75648817cada77266d48f6bbc85b0ab (diff)
Add get_stream() function for accessing the current stream (#70)
-rw-r--r--sounddevice.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/sounddevice.py b/sounddevice.py
index bc5aaa0..50bbb81 100644
--- a/sounddevice.py
+++ b/sounddevice.py
@@ -587,6 +587,26 @@ def get_status():
raise RuntimeError('play()/rec()/playrec() was not called yet')
+def get_stream():
+ """Get a reference to the current stream.
+
+ This applies only to streams created by calls to `play()`, `rec()`,
+ or `playrec()`.
+
+ Returns
+ -------
+ Stream
+ An `OutputStream`, `InputStream`, or `Stream` associated with
+ the last invocation of `play()`, `rec()` or `playrec()`
+ respectively.
+
+ """
+ if _last_callback:
+ return _last_callback.stream
+ else:
+ raise RuntimeError('play()/rec()/playrec() was not called yet')
+
+
def query_devices(device=None, kind=None):
"""Return information about available devices.