[pulseaudio-discuss] alsa sink latency - how to account for startup delay

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Mon Mar 28 14:16:19 UTC 2016


On 3/22/16 4:11 AM, Georg Chini wrote:
> Hi,
>
> when a sink is started, there is some delay before the first sample is
> really played.
> This delay is a constant part of the sink latency that will be always
> present, so the
> minimum sink latency cannot go below that start delay.
> Would it be acceptable to adjust the latency range for the device after
> each unsuspend
> to reflect that?
> USB devices (those I have access to) for example have a startup delay in
> the range of
> 10ms, but have a latency range that starts at 0.5ms which does not make
> a lot of sense
> in my opinion.
> The startup delay is not constant, so the minimum possible latency would
> vary.
>
> On the source side the startup delay is not relevant since it does not
> delay the signal.

Sorry I missed this thread last week.
At the risk of being pedantic, maybe you should consider two different 
concepts.
- cold latency: the time it takes for the audio device to render the 
first sample when first opened
- continuous latency: the time it takes to hear a sample after it's 
written to the ring buffer.

The cold latency is mostly what happens in the .prepare step at the 
driver level. It's very hard to estimate by software since you can't 
observe the analog output. It can also vary depending on platform 
states. The ALSA driver tells you however when it started pushing 
samples out after the .prepare step, the status.trigger_time value tells 
you what your starting point should be. All the smoothers should start 
from this value, not from the time you started pushing the samples in 
the sink.

The latency specified by PulseAudio is only related to the continuous 
latency - the total buffering. There is no need to take the startup 
delay into account as long as you use the trigger_time as your t0.
Some devices don't report trigger_time accurately but in the case of USB 
there were patches to fix this last year, look for the subject
"ALSA: usb: update trigger timestamp on first non-zero URB submitted"

Hope this helps
-Pierre




More information about the pulseaudio-discuss mailing list