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

Georg Chini georg at chini.tk
Tue Apr 12 14:21:31 UTC 2016


Hi Tanu,

I did a quick test, that verifies my assumption. Latency below always
refers to the end-to-end latency of module-loopback.

I put in a 2ms sleep before snd_pcm_start(), thereby introducing some
unexpected "extra extra delay". Naturally this will only work,
if snd_pcm_start() is really the moment where playback is started.

This way I could verify:

a) HDA cards are already running before snd_pcm_start():

With my code the latency is 2ms too short, because my code sees
2 ms "extra latency" that are in fact not there because the card is
already playing before snd_pcm_start(). But that is a bug in pulseaudio.
What needs to be changed to fix it?

Without my code the latency is the same as without sleep() because
snd_pcm_start() has no effect anyway.

b) My code does the right thing

If the sink is an USB sink (which seems really to start at snd_pcm_start())
the latency is correct with or without sleep as expected because the code
compensates the 2ms "extra delay".


I have however not been correct, when I said that without truncating the
negative "extra latencies" I am getting a more exact result. This can't be
true, because I do not know the exact start time of the card.
The offset that is applied in the end depends on a single measurement, if
that is wrong, the resulting latency will be wrong. So we have around
+/-100 usec offset for HDA and around +/-500 usec offset for USB.

Regards
             Georg


More information about the pulseaudio-discuss mailing list