Hi,
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* detectable.
Symptoms: 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, http://git.alsa-project.org/?p=alsa-plugins.git;a=commit;h=c20d516e229620129... 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? http://pulseaudio.org/report/1 Where on Ubuntu's launchpad? What do they now about the issue?
Regards, Jörg Höhle
On Fri, Sep 09, 2011 at 12:31:10PM +0200, Joerg-Cyril.Hoehle@t-systems.com wrote:
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 launchpad ticket I've been following is https://bugs.launchpad.net/ubuntu/+source/alsa-plugins/+bug/805940 Their solution was to introduce yet another option, handle_underrun=2, which handles underruns even better than handle_underrun=1! Or something. Really I don't know. handle_underrun=2 is now the new default, unless it's overridden by a user- or application-specified configuration. Which Wine does, so we no longer get this new-and-improved default... Have I mentioned my unending love for audio APIs?
Some testing has shown that handle_underrun=1 and handle_underrun=2 both work well with winealsa.drv. So we'll probably drop the handle_underrun=1 override after alsa-plugins 1.0.25 becomes common.
Andrew