First version enable timestamps

This commit is contained in:
Ronald van Elburg
2021-04-06 14:31:45 +02:00
parent 17f3b440cc
commit 3c3f0af74a
2 changed files with 26 additions and 2 deletions
+24
View File
@@ -852,6 +852,29 @@ Returns a tuple containing the seconds since epoch in the first element \n\
, nanoseconds in the second element, and number of frames available in \n\
the buffer at the time of the time stamp. \n");
static PyObject *
alsapcm_enable_timestamp(alsapcm_t *self, PyObject *args)
{
snd_pcm_sw_params_t* swParams;
snd_pcm_sw_params_alloca( &swParams);
snd_pcm_sw_params_current(self->handle, swParams);
snd_pcm_sw_params_set_tstamp_mode(self->handle, swParams, SND_PCM_TSTAMP_ENABLE);
snd_pcm_sw_params_set_tstamp_type(self->handle, swParams, SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY);
snd_pcm_sw_params(self->handle, swParams);
return Py_None;
}
PyDoc_STRVAR(alsapcm_enable_timestamp_doc,
"enable_timestamp() -> tuple\n\
\n\
Hic sunt dragonis \n");
// auxiliary function
@@ -1590,6 +1613,7 @@ static PyMethodDef alsapcm_methods[] = {
setperiodsize_doc},
{"htimestamp", (PyCFunction) alsapcm_htimestamp, METH_VARARGS,
pcm_htimestamp_doc},
{"enable_timestamp", (PyCFunction) alsapcm_enable_timestamp, METH_VARARGS, alsapcm_enable_timestamp_doc},
{"dumpinfo", (PyCFunction)alsapcm_dumpinfo, METH_VARARGS},
{"info", (PyCFunction)alsapcm_info, METH_VARARGS, pcm_info_doc},
{"getformats", (PyCFunction)alsapcm_getformats, METH_VARARGS, getformats_doc},
+2 -2
View File
@@ -54,8 +54,8 @@ if __name__ == '__main__':
periodsize=160, device=device)
print(inp.info())
help(inp.htimestamp)
# help(inp.htimestamp)
inp.enable_timestamp()
loops = 100000
while loops > 0:
loops -= 1