forked from auracaster/pyalsaaudio
On phys_from_sound: Small memory management fixes and code simplification. And add documentation on new functionality.
This commit is contained in:
+5
-15
@@ -830,14 +830,10 @@ they represent values stored by pyalsaaudio and they are prefixed with ' (call v
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
alsa_asoundlib_version(PyObject * module, PyObject *args)
|
alsa_asoundlib_version(PyObject * module, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *value;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,":asoundlib_version"))
|
if (!PyArg_ParseTuple(args,":asoundlib_version"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
value=PyUnicode_FromString(snd_asoundlib_version());
|
return PyUnicode_FromString(snd_asoundlib_version());
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(asoundlib_version_doc,
|
PyDoc_STRVAR(asoundlib_version_doc,
|
||||||
@@ -901,6 +897,7 @@ alsapcm_set_tstamp_mode(alsapcm_t *self, PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -917,9 +914,6 @@ alsapcm_get_tstamp_mode(alsapcm_t *self, PyObject *args)
|
|||||||
snd_pcm_tstamp_t mode;
|
snd_pcm_tstamp_t mode;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
||||||
PyObject *value;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,":get_tstamp_mode"))
|
if (!PyArg_ParseTuple(args,":get_tstamp_mode"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -941,8 +935,7 @@ alsapcm_get_tstamp_mode(alsapcm_t *self, PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = PyLong_FromUnsignedLong((unsigned long) mode);
|
return PyLong_FromUnsignedLong((unsigned long) mode);
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -981,6 +974,7 @@ alsapcm_set_tstamp_type(alsapcm_t *self, PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -996,9 +990,6 @@ alsapcm_get_tstamp_type(alsapcm_t *self, PyObject *args)
|
|||||||
snd_pcm_tstamp_type_t type;
|
snd_pcm_tstamp_type_t type;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
||||||
PyObject *value;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,":get_tstamp_type"))
|
if (!PyArg_ParseTuple(args,":get_tstamp_type"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1020,8 +1011,7 @@ alsapcm_get_tstamp_type(alsapcm_t *self, PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = PyLong_FromUnsignedLong((unsigned long) type);
|
return PyLong_FromUnsignedLong((unsigned long) type);
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
changed. Since 0.8, this functions returns the mixers for the default
|
||||||
device, not the mixers for the first card.
|
device, not the mixers for the first card.
|
||||||
|
|
||||||
|
.. function:: asoundlib_version()
|
||||||
|
|
||||||
|
Return a Python string containing the ALSA version found.
|
||||||
|
|
||||||
.. _pcm-objects:
|
.. _pcm-objects:
|
||||||
|
|
||||||
@@ -260,6 +263,56 @@ PCM objects have the following methods:
|
|||||||
The *eventmask* value is compatible with `poll.register`__ in the Python
|
The *eventmask* value is compatible with `poll.register`__ in the Python
|
||||||
:const:`select` module.
|
: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_
|
__ poll_objects_
|
||||||
|
|
||||||
**A few hints on using PCM devices for playback**
|
**A few hints on using PCM devices for playback**
|
||||||
|
|||||||
Reference in New Issue
Block a user