Skip to content

Commit 00255a0

Browse files
mgeierlarsoner
authored andcommitted
DOC: add information about fields of "action" and "stats"
1 parent a201f4a commit 00255a0

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

doc/api.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,28 @@ Common parameters that are shared by most commands:
3232

3333
All commands return a corresponding "action", which can be compared against the
3434
active `actions`, and can be used as input for `cancel()` and `wait()`.
35+
The fields of action objects are defined in C but can be accessed with
36+
Python (e.g. ``my_action.stats.min_blocksize``)
37+
*after* the command is finished:
3538

39+
.. literalinclude:: ../src/rtmixer.h
40+
:language: c
41+
:start-at: struct action
42+
:end-at: flexible array member
43+
:append: };
44+
45+
The ``stats`` field contains some statistics collected during playback/recording
46+
(again, *after* the command is finished):
47+
48+
.. literalinclude:: ../src/rtmixer.h
49+
:language: c
50+
:start-at: struct stats
51+
:end-at: }
52+
53+
These statistics are also collected for the whole runtime of a stream,
54+
where they are available as `stats` attribute (but only if the stream is
55+
*inactive*). The statistics of an *active* stream can be obtained
56+
(and at the same time reset) with `fetch_and_reset_stats()`.
3657

3758
.. autoclass:: Mixer
3859
:members: play_buffer, play_ringbuffer, actions, cancel, wait, stats,

src/rtmixer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def cancel(self, action, time=0, allow_belated=True):
8282
def fetch_and_reset_stats(self, time=0, allow_belated=True):
8383
"""Fetch and reset over-/underflow statistics of the stream.
8484
85+
The statistics will be available in the ``stats`` field of the
86+
returned action.
87+
8588
"""
8689
action = _ffi.new('struct action*', dict(
8790
type=FETCH_AND_RESET_STATS,

0 commit comments

Comments
 (0)