Skip to content

Commit

Permalink
DOC: add information about fields of "action" and "stats"
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier authored and larsoner committed May 26, 2021
1 parent a201f4a commit 00255a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,28 @@ Common parameters that are shared by most commands:

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

.. literalinclude:: ../src/rtmixer.h
:language: c
:start-at: struct action
:end-at: flexible array member
:append: };

The ``stats`` field contains some statistics collected during playback/recording
(again, *after* the command is finished):

.. literalinclude:: ../src/rtmixer.h
:language: c
:start-at: struct stats
:end-at: }

These statistics are also collected for the whole runtime of a stream,
where they are available as `stats` attribute (but only if the stream is
*inactive*). The statistics of an *active* stream can be obtained
(and at the same time reset) with `fetch_and_reset_stats()`.

.. autoclass:: Mixer
:members: play_buffer, play_ringbuffer, actions, cancel, wait, stats,
Expand Down
3 changes: 3 additions & 0 deletions src/rtmixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def cancel(self, action, time=0, allow_belated=True):
def fetch_and_reset_stats(self, time=0, allow_belated=True):
"""Fetch and reset over-/underflow statistics of the stream.
The statistics will be available in the ``stats`` field of the
returned action.
"""
action = _ffi.new('struct action*', dict(
type=FETCH_AND_RESET_STATS,
Expand Down

0 comments on commit 00255a0

Please sign in to comment.