[MMEBUDDY]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 31 Jan 2010 19:09:30 +0000 (19:09 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 31 Jan 2010 19:09:30 +0000 (19:09 +0000)
- Hackfix corruption of audio buffer list which made the playback thread spin forever on an already played buffer.
- Tested with Winamp / VLC / mplay32 with Vbox 3.1.2

svn path=/trunk/; revision=45360

reactos/lib/drivers/sound/mmebuddy/wave/header.c
reactos/lib/drivers/sound/mmebuddy/wave/streaming.c

index ac1c99b..bf5b80b 100644 (file)
@@ -248,10 +248,18 @@ EnqueueWaveHeader(
     {
         /* There are already queued headers - make this one the tail */
         SND_TRACE(L"Enqueued next wave header\n");
-        SoundDeviceInstance->TailWaveHeader->lpNext = WaveHeader;
-        SoundDeviceInstance->TailWaveHeader = WaveHeader;
 
-        DoWaveStreaming(SoundDeviceInstance);
+        /* FIXME - Make sure that the buffer has not already been added to the list */
+        if ( SoundDeviceInstance->TailWaveHeader != WaveHeader )
+        {
+            SND_ASSERT(SoundDeviceInstance->TailWaveHeader != WaveHeader);
+
+            SoundDeviceInstance->TailWaveHeader->lpNext = WaveHeader;
+            SoundDeviceInstance->TailWaveHeader = WaveHeader;
+            DUMP_WAVEHDR_QUEUE(SoundDeviceInstance);
+
+            DoWaveStreaming(SoundDeviceInstance);
+        }
     }
 
     DUMP_WAVEHDR_QUEUE(SoundDeviceInstance);
index f910bf9..a280933 100644 (file)
@@ -77,6 +77,7 @@ DoWaveStreaming(
         {
             {
                 /* Move on to the next header */
+                SND_ASSERT(Header != Header->lpNext);
                 Header = Header->lpNext;
             }
         }
@@ -209,9 +210,9 @@ CompleteIO(
         }
                else
                {
-            SND_TRACE(L"%d/%d bytes of wavehdr completed\n", HdrExtension->BytesCompleted, WaveHdr->dwBufferLength);
             /* Partially completed */
             HdrExtension->BytesCompleted += dwNumberOfBytesTransferred;
+            SND_TRACE(L"%d/%d bytes of wavehdr completed\n", HdrExtension->BytesCompleted, WaveHdr->dwBufferLength);
             break;
                }