[alsa-devel] timestamps
How can I get the CLOCK_MONOTONIC timestamp for the first sample in the data I get from snd_pcm_readi()?
/Jonas
Hi,
On Wed, 21 Apr 2010, Jonas Holmberg wrote:
How can I get the CLOCK_MONOTONIC timestamp for the first sample in the data I get from snd_pcm_readi()?
before reading the data, take the current timestamp (with clock_gettime) and subtract snd_pcm_delay() for the stream (see the API docs for snd_pcm_delay() for more details).
The accuracy of the returned value depends on the driver/hw's ability to report accurate delay values.
PS Alternate strategy is to use SND_PCM_TSTAMP_MMAP mode, in which you can query (with snd_pcm_htimestamp()) the timestamp of last period elapsed event. See the alsa-lib PCM API docs for details. With certain drivers/hw, this is the only way to get accurate estimates for delay.
participants (2)
-
Jonas Holmberg
-
Kai Vehmanen