What is the PulseAudio underrun bug?

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Fri Sep 9 05:31:10 CDT 2011


As I see that the PA team is preparing release candidates for 1.0, I
wonder whether the Wine team communicated them the issues we face.
Browsing open tickets http://pulseaudio.org/report/1 I found nothing obvious.

The PA bug, as I face it in Ubuntu Lucid, is not something that
happens randomly after N minutes or hours.  It is *immediately*

1. winecfg audio test hangs.

But Wine is a complex program, so I wrote a trivial one as follows:
 - set generic hw_params
 - prefill snd_pcm_write with e.g. 100ms of data;
 - start ALSA or use hw_params_set_start_threshold;
 - print out snd_pcm_state, snd_pcm_avail_update and snd_pcm_delay in a loop.

2. avail_update and avail_delay will freeze approx. at the time
   underrun would have happened with plug:dmix or plughw:0.
   In particular, delay will not decrease below < 0.

   By contrast, dmix or hw would see avail_update grow continuously,
   far above buffer_size, while delay decreases towards minus infinity
   -- regardless of whether XRUN state was entered or still RUNNING
   playing silence.

3. Optionally, XRUN mode is never entered, PA claims to be RUNNING.
   (XRUN is not a necessity, depending on hw_params_set_silence_*)

>From there on, more snd_pcm_write(N frames) will not be heard, and
avail_update() and delay() will solely bump to reflect that N frames
have been queued, and remain frozen.

snd_pcm_reset() won't help.

snd_pcm_drain() will surprisingly play the buffered audio.  Note that
in non-blocking mode, this function will return -11 with "dmix" or
"hw" ALSA devices, so here again PA differs from others.

It looks like PA's front end (claiming to be running) has lost sync
with its backend (which apparently stopped).

4. I don't know why and when, but the damage is not always limited to
   this one process.  Sometimes the PA server will need to be
   restarted (pactl exit) otherwise no more sound will play for more
   than a click's time.  It obviously corrupted its data structures.

Andrew Eikum found out that activating the handle_underrun
configuration in the newest alsa plugin package (released 2011-01-31!)
allows to work around the bug.

However when I read the comment to the patch,
I've the impression that using handle_underrun is backwards and is
*not* the recommended way to use PulseAudio.

IOW, PA without handle_underrun is subject to the underrun bug
and that is abnormal behaviour.
Or was it?  Does the brandnew PA RC exhibit sane behaviour?

Which is the "need handle_underrun" ticket in PA's bug tracker?
Where on Ubuntu's launchpad?
What do they now about the issue?

	Jörg Höhle

More information about the wine-devel mailing list