diff options
| author | David A. Riggs <david.a.riggs@gmail.com> | 2017-01-26 11:21:00 -0800 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2017-01-26 20:21:00 +0100 |
| commit | 4d524714a9bc0eef8fa880bc58594bd5792cd6dc (patch) | |
| tree | 7f54652f280899d7c0c7ca219c1b2a0c28d9234a | |
| parent | b780a2fcb75648817cada77266d48f6bbc85b0ab (diff) | |
Add get_stream() function for accessing the current stream (#70)
| -rw-r--r-- | sounddevice.py | 20 |
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. |
