Skip to content

Commit d335cf5

Browse files
committed
Add stats attribute
1 parent 1daf644 commit d335cf5

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ API Documentation
1010
.. automodule:: rtmixer
1111

1212
.. autoclass:: Mixer
13-
:members: play_buffer, play_ringbuffer, actions, cancel, wait
13+
:members: play_buffer, play_ringbuffer, actions, cancel, wait, stats
1414
:undoc-members:
1515

1616
.. autoclass:: Recorder

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
install_requires=[
2222
'CFFI>=1', # for _cffi_backend
2323
'pa_ringbuffer', # for init()
24-
'sounddevice>0.3.6',
24+
'sounddevice>0.3.9',
2525
],
2626
author='Matthias Geier',
2727
author_email='Matthias.Geier@gmail.com',

src/rtmixer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ def actions(self):
4747
self._drain_result_q()
4848
return self._actions
4949

50+
@property
51+
def stats(self):
52+
"""Get over-/underflow statistics from an *inactive* stream.
53+
54+
To get statistics from an :attr:`~sounddevice.Stream.active`
55+
stream, use `fetch_and_reset_stats()`.
56+
57+
"""
58+
if self.active:
59+
raise RuntimeError('Accessing .stats on an active stream')
60+
return _ffi.new('struct stats*', self._state.stats)
61+
5062
def cancel(self, action, time=0, allow_belated=True):
5163
"""Initiate stopping a running action.
5264

0 commit comments

Comments
 (0)