[alsa-devel] Calculated average playback latency

Jean-Yves Avenard jyavenard at gmail.com
Tue Dec 14 13:30:23 CET 2010

Hi there.

I am involved in maintaining the mythtv audio code.

Today one of our user complained that he couldn't get any audio out ,
even though everything was properly configured on his side.

By default, Myth uses mmap access ; unless we found out that the audio
device doesn't allow mmap (e.g. snd_pcm_hw_params_set_access(handle,

Problem, turned out his was using a USB audio device, and
snd_pcm_hw_params_set_access didn't return any error.

It's not the first time we're having such issues, so I decided to stop
using mmap and instead use snd_pcm_writei.

Now on my system, this has added quite a bit of latency and the A/V
sync isn't perfect anymore...

Is there an official way to calculate an average system latency
(doesn't need to be perfectly accurate).

I couldn't find obvious references on how to perform such task.

I find some references in program like mplayer or jack using

Would anyone be kind enough to point me to some documentation or
explain to me how I could calculate the average latency between the
time you start playback and the time sounds actually comes out.

Thank you in advance

More information about the Alsa-devel mailing list