winealsa: Fix freezing winmm test

Francois Gouget fgouget at codeweavers.com
Mon Jul 19 13:13:50 CDT 2004


The winmm test would systematically freeze when playing the 48000x8x1 
winmm test with the winealsa backend.

The reason was that snd_pcm_delay() would return 388 indefinitely which 
would cause wodPlayer_NotifyCompletions() to never detect the completion 
of the WaveHdr. Fortunately I found the following email:
http://www.mail-archive.com/alsa-devel@lists.sourceforge.net/msg12704.html

 > after calling snd_pcm_delay(), call snd_pcm_state() and make sure it
 > is in RUNNING state, otherwise, values returned from snd_pcm_delay()
 > are meaningless.

I modified wodUpdatePlayedTotal() as recommended and that fixed the 
problem. For reference, the state I'm in when snd_pcm_delay() remains 
stuck at 388 is SND_PCM_STATE_XRUN which I interpret as meaning that the 
buffer has been fully played.


Changelog:

  * dlls/winmm/winealsa/audio.c

    Francois Gouget <fgouget at codeweavers.com>
    Check that we are still playing in wodUpdatePlayedTotal(). If not, 
then the value returned by snd_pcm_delay() is not usable so assume delay=0.
    This gets the winmm test to complete in interactive mode with winealsa.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/winmm/winealsa/audio.c
===================================================================
RCS file: /var/cvs/wine/dlls/winmm/winealsa/audio.c,v
retrieving revision 1.45
diff -u -r1.45 audio.c
--- dlls/winmm/winealsa/audio.c	14 Jun 2004 16:59:34 -0000	1.45
+++ dlls/winmm/winealsa/audio.c	19 Jul 2004 16:39:10 -0000
@@ -998,10 +998,12 @@
  */
 static BOOL wodUpdatePlayedTotal(WINE_WAVEOUT* wwo, snd_pcm_status_t* ps)
 {
-   snd_pcm_sframes_t delay = 0;
-   snd_pcm_delay(wwo->p_handle, &delay);
-   wwo->dwPlayedTotal = wwo->dwWrittenTotal - snd_pcm_frames_to_bytes(wwo->p_handle, delay);
-   return TRUE;
+    snd_pcm_sframes_t delay = 0;
+    snd_pcm_delay(wwo->p_handle, &delay);
+    if (snd_pcm_state(wwo->p_handle) != SND_PCM_STATE_RUNNING)
+        delay=0;
+    wwo->dwPlayedTotal = wwo->dwWrittenTotal - snd_pcm_frames_to_bytes(wwo->p_handle, delay);
+    return TRUE;
 }
 
 /**************************************************************************


More information about the wine-patches mailing list