[pulseaudio-discuss] My attempt to reduce latency with pacat and tvtime

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Mon May 21 06:01:08 PDT 2012


> Since I've posted the above I've refined my patch a bit, which I've 
> attached, but I've also explored an additional cause of latency in the 
> PulseAudio server. I've found that, if for some reason, there is an 
> underrun the watermark or latency is increased via 
> increase_watermark() in alsa-source.c and alsa-sink.c. That probably 
> makes sense in a lot of cases, but in the case of watching TV via 
> tvtime I'd rather suffer a fleeting glitch due to underrun than a 
> longer lasting A/V sync issue.

I am not sure if there's really a problem. Increasing the audio latency 
doesn't necessarily result in A/V sync issues. As long as the A/V sync 
is done by querying how many samples are queued instead of using the 
number of samples pushed into PulseAudio, you should be able to use 
pretty much whatever buffer size you want. It's the same issue with 
ALSA, if you use large buffers and base the A/V on the number of samples 
written to the ring buffer, A/V sync will be off. Use snd_pcm_delay() 
and you'll be fine.
> I don't think the attached 
> "pulseaudio-limited-watermark-experimental.diff" patch is ideal which 
> why I marked it "experimental". Consequently I'm curious if there is 
> potential for it to evolve into a submitable patch. Should the 50 msec 
> limit that I've imposed in fix_tsched_watermark() be configurable? 
> Would it be preferable to decrease the watermark more aggressively in 
> decrease_watermark()?
This is the most complex part of PulseAudio IMO. I think the problem is 
not really the watermark but the latency. Once the latency, i.e. the 
amount of buffering, is increased, it's never decreased again.
-Pierre



More information about the pulseaudio-discuss mailing list