[alsa-devel] Latency and timestamps

Claudio Matsuoka cmatsuoka at gmail.com
Tue Nov 20 01:46:31 CET 2007


I'm adding latency control to an application and didn't find much
documentation about the pcm status functions aside from a very brief
description and the latency.c example. What exactly are the "trigger
timestamp" and "now timestamp" returned by
snd_pcm_status_get_trigger_tstamp() and snd_pcm_status_get_tstamp()? I
collected both from my output pcm handle to find values (in
tv_sec.tv_usec format) such as

1195518180.938427 938427.557702
1195518180.938441 938441.557702
1195518181.300395 300395.557702
1195518181.300441 300441.557702

where the "trigger" tv_sec matches the "now" tv_usec, and the
"trigger" tv_usec varies in large steps. Also the example latency.c

00703                 showinmax(in_max);
00704                 if (p_tstamp.tv_sec == p_tstamp.tv_sec &&
00705                     p_tstamp.tv_usec == c_tstamp.tv_usec)
00706                         printf("Hardware sync\n");
00707                 snd_pcm_drop(chandle);

In line 704, shouldn't it be p_tstamp.tv_sec == c_tstamp.tv_sec?

My final goal is to sync on-screen events with the sound output. I'd
like to do something like storing output metadata associated with a
certain timestamp and collecting it back based on the timestamp of the
currently playing pcm data (like the OSS sequencer echoback events),
is that possible, or is there a better way to do this?

More information about the Alsa-devel mailing list