[PATCH 1/2] winealsa.drv: Tell ALSA to play silence during underruns

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Mon Aug 8 10:41:32 CDT 2011


Hi,

Andrew Eikum wrote:
>playing silence instead of garbage during underruns makes sense anyway.
>+    if((err = snd_pcm_sw_params_set_silence_size(This->pcm_handle,
>+                    sw_params, boundary)) < 0){

That's exactly how I feel about it, remember
http://www.winehq.org/pipermail/wine-devel/2011-August/091333.html

I wonder why nobody changed that during the last 10 years of winealsa.drv.

So I played with ALSA over the last days and now I'm beginning to
understand why people are so upset about it.

Under Ubuntu Intrepid with built-in Intel AC'97 audio, "plughw:0"
which I used this time differs a lot from dmix which I talked about last week.

When plughw:0 loops around its buffer (stop_threshold=boundary),
writing after an underrun may cause some of the last part of your
audio data to be heard first, then some silence, then only the
beginning of the audio data :-(  Doesn't that sound like bug #XY?
Also, sound typically does not start immediately following snd_pcm_writei().

It sounds as if the write occurs to a fictive play position (modulo
underrun), while the HW pointer loops across the buffer.  That may
be normal for somebody used to ALSA -- after all, the documentation
says "device will do the endless loop in the ring buffer" -- but it's
not what I naively expected.
snd_pcm_reset does not help (presumably there's still an underrun
between reset and the following write).

Remember that dmix behaves differently: it will play silence instead
of your data until you've fed so much data that you managed to
fill the underrun gap (avail_update again <= buffer_size).

As a conclusion, the looping mode is not what Wine needs...

I'm still wondering what snd_pcm_sw_params best fit Wine's (mmdevapi's) needs.
Any hints?

BTW, perhaps I wrote into illegal memory during my experiments, but I
had a few cases where plughw:0 suddenly stopped updating the counters
(avail_update & delay), playing nothing while still pretending to be
in RUNNING state...  IIRC, snd_pcm_drop and prepare helped.

Thank you for suggestions about good use of snd_pcm_sw_params,
 Jörg Höhle



More information about the wine-devel mailing list