diff --git a/alsaaudio.c b/alsaaudio.c index 550a562..ce9b610 100644 --- a/alsaaudio.c +++ b/alsaaudio.c @@ -830,14 +830,10 @@ they represent values stored by pyalsaaudio and they are prefixed with ' (call v static PyObject * alsa_asoundlib_version(PyObject * module, PyObject *args) { - PyObject *value; - if (!PyArg_ParseTuple(args,":asoundlib_version")) return NULL; - value=PyUnicode_FromString(snd_asoundlib_version()); - - return value; + return PyUnicode_FromString(snd_asoundlib_version()); } PyDoc_STRVAR(asoundlib_version_doc, @@ -901,6 +897,7 @@ alsapcm_set_tstamp_mode(alsapcm_t *self, PyObject *args) return NULL; } + Py_INCREF(Py_None); return Py_None; } @@ -917,9 +914,6 @@ alsapcm_get_tstamp_mode(alsapcm_t *self, PyObject *args) snd_pcm_tstamp_t mode; int err; - - PyObject *value; - if (!PyArg_ParseTuple(args,":get_tstamp_mode")) return NULL; @@ -941,8 +935,7 @@ alsapcm_get_tstamp_mode(alsapcm_t *self, PyObject *args) return NULL; } - value = PyLong_FromUnsignedLong((unsigned long) mode); - return value; + return PyLong_FromUnsignedLong((unsigned long) mode); } @@ -981,6 +974,7 @@ alsapcm_set_tstamp_type(alsapcm_t *self, PyObject *args) return NULL; } + Py_INCREF(Py_None); return Py_None; } @@ -996,9 +990,6 @@ alsapcm_get_tstamp_type(alsapcm_t *self, PyObject *args) snd_pcm_tstamp_type_t type; int err; - - PyObject *value; - if (!PyArg_ParseTuple(args,":get_tstamp_type")) return NULL; @@ -1020,8 +1011,7 @@ alsapcm_get_tstamp_type(alsapcm_t *self, PyObject *args) return NULL; } - value = PyLong_FromUnsignedLong((unsigned long) type); - return value; + return PyLong_FromUnsignedLong((unsigned long) type); } diff --git a/doc/libalsaaudio.rst b/doc/libalsaaudio.rst index c9b9c5e..4e9a4e9 100644 --- a/doc/libalsaaudio.rst +++ b/doc/libalsaaudio.rst @@ -97,6 +97,9 @@ The :mod:`alsaaudio` module defines functions and classes for using ALSA. changed. Since 0.8, this functions returns the mixers for the default device, not the mixers for the first card. +.. function:: asoundlib_version() + + Return a Python string containing the ALSA version found. .. _pcm-objects: @@ -260,6 +263,56 @@ PCM objects have the following methods: The *eventmask* value is compatible with `poll.register`__ in the Python :const:`select` module. +.. method:: PCM.set_tstamp_mode([mode=PCM_TSTAMP_ENABLE]) + + Set the ALSA timestamp mode on the device. The mode argument can be set to + either :const:`PCM_TSTAMP_NONE` or :const:`PCM_TSTAMP_ENABLE`. + +.. method:: PCM.get_tstamp_mode() + + Return the integer value corresponding to the ALSA timestamp mode. The + return value can be either :const:`PCM_TSTAMP_NONE` or :const:`PCM_TSTAMP_ENABLE`. + +.. method:: PCM.set_tstamp_type([type=PCM_TSTAMP_TYPE_GETTIMEOFDAY]) + + Set the ALSA timestamp mode on the device. The type argument + can be set to either :const:`PCM_TSTAMP_TYPE_GETTIMEOFDAY`, + :const:`PCM_TSTAMP_TYPE_MONOTONIC` or :const:`PCM_TSTAMP_TYPE_MONOTONIC_RAW`. + +.. method:: PCM.get_tstamp_type() + + Return the integer value corresponding to the ALSA timestamp type. The + return value can be either :const:`PCM_TSTAMP_TYPE_GETTIMEOFDAY`, + :const:`PCM_TSTAMP_TYPE_MONOTONIC` or :const:`PCM_TSTAMP_TYPE_MONOTONIC_RAW`. + +.. method:: PCM.htimestamp() + + Return a Python tuple *(seconds, nanoseconds, frames_available_in_buffer)*. + + The type of output is controlled by the tstamp_type, as described in the table below. + + ================================= =========================================== + Timestamp Type Description + ================================= =========================================== + ``PCM_TSTAMP_TYPE_GETTIMEOFDAY`` System-wide realtime clock with seconds + since epoch. + ``PCM_TSTAMP_TYPE_MONOTONIC`` Monotonic time from an unspecified starting + time. Progress is NTP synchronized. + ``PCM_TSTAMP_TYPE_MONOTONIC_RAW`` Monotonic time from an unspecified starting + time using only the system clock. + ================================= =========================================== + + The timestamp mode is controlled by the tstamp_mode, as described in the table below. + + ================================= =========================================== + Timestamp Mode Description + ================================= =========================================== + ``PCM_TSTAMP_NONE`` No timestamp. + ``PCM_TSTAMP_ENABLE`` Update timestamp at every hardware position + update. + ================================= =========================================== + + __ poll_objects_ **A few hints on using PCM devices for playback**