[alsa-devel] how to obtain hardware playback position after underrun?
tiwai at suse.de
Fri Apr 27 14:39:24 CEST 2012
At Wed, 25 Apr 2012 18:42:16 +0200,
Maarten de Boer wrote:
> I am trying to figure out how to obtain the hardware playback position
> after an underrun occured. When I have no underruns, I can simply keep
> track of the time by counting the samples processed. (I am using
> snd_pcm_mmap_commit). But in the unlucky event an underrun occurs, I
> would like to know what the playback position would have been without
> any underrun. Is this possible? I have been looking at the API docs,
> and at the source code, but to no avail.
In general, the driver doesn't give such information directly. When
an underrun happens, it depends on the hardware what happens at the
next. It might stop immediately, reset, or whatever.
The driver can take a timestamp at the time the underrun is detected,
at most. You can guess from this value.
Note that this doesn't guarantee the exact time, though. The
detection is usually done at the period boundary unless the hardware
generates the underrun event or the position callback casually detects
More information about the Alsa-devel