Wine OSS fix

eric pouech eric.pouech at wanadoo.fr
Thu Apr 12 16:14:45 CDT 2001


this patch mainly fixes some recording issues. When several buffers
were submitted as storage, in some cases (when callback did modify
the just recorded buffer), the next buffer to be recorded was lost
from the inner recorder state, leading to recording data loss

it also fixes some wrong parameter for notification (but since the
parameter is unused, it shouldn't matter)

A+
-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: ossaudio
ChangeLog: fixed some buffers issue in recording
	zeroed unnecessary second parameter for WIM_DATA notification
GenDate: 2001/04/12 21:06:00 UTC
ModifiedFiles: dlls/winmm/wineoss/audio.c
AddedFiles: 
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.38
diff -u -u -r1.38 audio.c
--- dlls/winmm/wineoss/audio.c	2001/03/21 03:37:33	1.38
+++ dlls/winmm/wineoss/audio.c	2001/04/12 20:52:25
@@ -354,8 +357,7 @@
 /**************************************************************************
  * 			OSS_NotifyClient			[internal]
  */
-static DWORD OSS_NotifyClient(UINT wDevID, WORD wMsg, DWORD dwParam1, 
-			      DWORD dwParam2)
+static DWORD OSS_NotifyClient(UINT wDevID, WORD wMsg, DWORD dwParam1, DWORD dwParam2)
 {
     TRACE("wDevID = %04X wMsg = 0x%04x dwParm1 = %04lX dwParam2 = %04lX\n",wDevID, wMsg, dwParam1, dwParam2);
     
@@ -1759,11 +1771,9 @@
         {
             lpWaveHdr = wwi->lpQueuePtr;
 
-
 	    ioctl(wwi->unixdev, SNDCTL_DSP_GETISPACE, &info);
             TRACE("info={frag=%d fsize=%d ftotal=%d bytes=%d}\n", info.fragments, info.fragsize, info.fragstotal, info.bytes);
 
-
             /* read all the fragments accumulated so far */
             while ((info.fragments > 0) && (wwi->lpQueuePtr))
             {
@@ -1786,17 +1796,20 @@
 			/* buffer is full. notify client */
 			if (lpWaveHdr->dwBytesRecorded == lpWaveHdr->dwBufferLength) 
 			{
+			    /* must copy the value of next waveHdr, because we have no idea of what
+			     * will be done with the content of lpWaveHdr in callback
+			     */
+			    LPWAVEHDR	lpNext = lpWaveHdr->lpNext;
+
 			    lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
 			    lpWaveHdr->dwFlags |=  WHDR_DONE;
 
-			    if (OSS_NotifyClient(uDevID, 
-						 WIM_DATA, 
-						 (DWORD)lpWaveHdr, 
-                                                 lpWaveHdr->dwBytesRecorded) != MMSYSERR_NOERROR) 
+			    if (OSS_NotifyClient(uDevID, WIM_DATA, 
+						 (DWORD)lpWaveHdr, 0) != MMSYSERR_NOERROR) 
 			    {
 				WARN("can't notify client !\n");
 			    }
-			    lpWaveHdr = wwi->lpQueuePtr = lpWaveHdr->lpNext;
+			    lpWaveHdr = wwi->lpQueuePtr = lpNext;
 			}
                     }
                 }
@@ -1826,28 +1839,27 @@
                         /* client buffer is full. notify client */
                         if (lpWaveHdr->dwBytesRecorded == lpWaveHdr->dwBufferLength) 
                         {
+			    /* must copy the value of next waveHdr, because we have no idea of what
+			     * will be done with the content of lpWaveHdr in callback
+			     */
+			    LPWAVEHDR	lpNext = lpWaveHdr->lpNext;
+			    TRACE("lpNext=%p\n", lpNext);
+
                             lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
                             lpWaveHdr->dwFlags |=  WHDR_DONE;
 
-                            if (OSS_NotifyClient(uDevID, 
-                                                 WIM_DATA, 
-                                                 (DWORD)lpWaveHdr, 
-                                                 lpWaveHdr->dwBytesRecorded) != MMSYSERR_NOERROR) 
+                            if (OSS_NotifyClient(uDevID, WIM_DATA, 
+                                                 (DWORD)lpWaveHdr, 0) != MMSYSERR_NOERROR) 
                             {
                                 WARN("can't notify client !\n");
                             }
 				   
-                            if (lpWaveHdr->lpNext)
-                            {	
-                                lpWaveHdr = lpWaveHdr->lpNext;
-                                wwi->lpQueuePtr = lpWaveHdr;
-                            }
-                            else
-                            {
+			    wwi->lpQueuePtr = lpWaveHdr = lpNext;
+			    if (!lpNext && bytesRead) {
                                 /* no more buffer to copy data to, but we did read more. 
                                  * what hasn't been copied will be dropped
                                  */ 
-                                if (bytesRead) WARN("buffer over run! %lu bytes dropped.\n", bytesRead);
+                                WARN("buffer under run! %lu bytes dropped.\n", bytesRead);
                                 wwi->lpQueuePtr = NULL;
                                 break;
                             }
@@ -1910,8 +1922,8 @@
 		    lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
 		    lpWaveHdr->dwFlags |= WHDR_DONE;
 	
-		    if (OSS_NotifyClient(uDevID, WIM_DATA, (DWORD)lpWaveHdr, 
-					 lpWaveHdr->dwBytesRecorded) != MMSYSERR_NOERROR) {
+		    if (OSS_NotifyClient(uDevID, WIM_DATA, 
+					 (DWORD)lpWaveHdr, 0) != MMSYSERR_NOERROR) {
 			WARN("can't notify client !\n");
 		    }
 		}


More information about the wine-patches mailing list