[alsa-devel] Calculated average playback latency
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, params, SND_PCM_ACCESS_MMAP_INTERLEAVED) errored)
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 snd_pcm_status_get_trigger_tstamp
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 Jean-Yves
Jean-Yves Avenard wrote:
By default, Myth uses mmap access
Why?
Problem, turned out his was using a USB audio device, and snd_pcm_hw_params_set_access didn't return any error.
USB audio devices do support mmap.
... 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...
Using mmap neither reduces latency, nor does it improve synchronization.
Is there an official way to calculate an average system latency (doesn't need to be perfectly accurate).
Not the average, but try snd_pcm_delay().
Regards, Clemens
participants (2)
-
Clemens Ladisch
-
Jean-Yves Avenard