[alsa-devel] sound: ALSA PCM Timestamps

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Wed May 23 09:54:15 EDT 2018


On 5/23/18 8:00 AM, Muni Sekhar wrote:
> [ Please keep me in CC as I'm not subscribed to the list]
> 
> Hi All,
> 
> There are several time stamping functions in ALSA:
> 
> 
> snd_pcm_status_get_trigger_tstamp
> 
> snd_pcm_status_get_trigger_htstamp
> 
> snd_pcm_status_get_tstamp
> 
> snd_pcm_status_get_htstamp
> 
> snd_pcm_status_get_audio_htstamp
> 
> snd_pcm_status_get_driver_htstamp

the *_tstamp functions work with a 'struct timeval' which provides 
microsecond resolution.
The *_stamp functions work with a 'struct timespec' which provides 
nanosecond resolution.

The trigger_*tstamp returns the time when the stream started (typically 
when the DMA starts).
The get_tstamp returns the current timestamp measured with the regular 
timekeeping functions, which by subtracting the trigger timestamp 
provides the elapsed time since the start. You can specify if you want 
the REALTIME/MONOTONIC/MONOTONIC_RAW timestamp type, depending on your 
application.
The audio timestamp returns the current timestamp but measured using 
audio-specific counters. If the audio clocks are not aligned with the 
system time (e.g. if they use different oscillators or the audio clock 
source is external), there will be a drift between audio timestamps and 
system timestamp.


> 
> 
> 
> I would like to understand what points in time the resulting functions
> represent and what is the corresponding kernel mode callback for those
> API’s.
> 
> 
> I'd be really grateful if someone took the time to help me clearing my doubt.
> 
> 
> 




More information about the Kernelnewbies mailing list