[14/16] winecoreaudio: Merge wodReset and wodHelper_Reset.

Ken Thomases ken at codeweavers.com
Thu Dec 21 03:49:58 CST 2006


wodReset does almost nothing but call wodHelper_Reset.  wodHelper_Reset has
a large chunk of unreachable code, because it's only ever called with TRUE
for its "reset" parameter.  Once that unreachable code is removed, it's so
small that it might as well be inlined.
---
  dlls/winmm/winecoreaudio/audio.c |  100 +++++++++++---------------------------
  1 files changed, 30 insertions(+), 70 deletions(-)
-------------- next part --------------
diff --git a/dlls/winmm/winecoreaudio/audio.c b/dlls/winmm/winecoreaudio/audio.c
index 901b7dd..94fe157 100644
--- a/dlls/winmm/winecoreaudio/audio.c
+++ b/dlls/winmm/winecoreaudio/audio.c
@@ -971,75 +971,6 @@ static void wodHelper_NotifyCompletions(
     }
 }
 
-/**************************************************************************
-* 				wodHelper_Reset			[internal]
-*
-* Resets current output stream.
-*/
-static  DWORD  wodHelper_Reset(WINE_WAVEOUT* wwo, BOOL reset)
-{
-    OSStatus status;
-
-    FIXME("\n");
-   
-    /* updates current notify list */
-    /* if resetting, remove all wave headers and notify client that all headers were completed */
-    wodHelper_NotifyCompletions(wwo, reset);
-    
-    pthread_mutex_lock(&wwo->lock);
-    
-    if (reset)
-    {
-        wwo->lpPlayPtr = wwo->lpQueuePtr = wwo->lpLoopPtr = NULL;
-        wwo->state = WINE_WS_STOPPED;
-        wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
-        
-        wwo->dwPartialOffset = 0;        /* Clear partial wavehdr */
-    } 
-    else
-    {
-        if (wwo->lpLoopPtr)
-        {
-            /* complicated case, not handled yet (could imply modifying the loop counter) */
-            FIXME("Pausing while in loop isn't correctly handled yet, except strange results\n");
-            wwo->lpPlayPtr = wwo->lpLoopPtr;
-            wwo->dwPartialOffset = 0;
-            wwo->dwWrittenTotal = wwo->dwPlayedTotal; /* this is wrong !!! */
-        } else
-        {
-            LPWAVEHDR   ptr;
-            DWORD       sz = wwo->dwPartialOffset;
-            
-            /* reset all the data as if we had written only up to lpPlayedTotal bytes */
-            /* compute the max size playable from lpQueuePtr */
-            for (ptr = wwo->lpQueuePtr; ptr && ptr != wwo->lpPlayPtr; ptr = ptr->lpNext)
-            {
-                sz += ptr->dwBufferLength;
-            }
-            
-            /* because the reset lpPlayPtr will be lpQueuePtr */
-            if (wwo->dwWrittenTotal > wwo->dwPlayedTotal + sz) ERR("doh\n");
-            wwo->dwPartialOffset = sz - (wwo->dwWrittenTotal - wwo->dwPlayedTotal);
-            wwo->dwWrittenTotal = wwo->dwPlayedTotal;
-            wwo->lpPlayPtr = wwo->lpQueuePtr;
-        }
-        
-        wwo->state = WINE_WS_PAUSED;
-    }
-
-    pthread_mutex_unlock(&wwo->lock);
-
-    status = AudioOutputUnitStart(wwo->audioUnit);
-
-    if (status) {
-        ERR( "AudioOutputUnitStart return %c%c%c%c\n",
-             (char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
-        return MMSYSERR_ERROR; /* FIXME return an error based on the OSStatus */
-    }
-
-    return MMSYSERR_NOERROR;
-}
-
 
 /**************************************************************************
 * 				wodWrite			[internal]
@@ -1184,6 +1115,9 @@ static DWORD wodRestart(WORD wDevID)
 */
 static DWORD wodReset(WORD wDevID)
 {
+    WINE_WAVEOUT* wwo;
+    OSStatus status;
+
     TRACE("(%u);\n", wDevID);
     
     if (wDevID >= MAX_WAVEOUTDRV)
@@ -1191,8 +1125,34 @@ static DWORD wodReset(WORD wDevID)
         WARN("bad device ID !\n");
         return MMSYSERR_BADDEVICEID;
     }
+
+    wwo = &WOutDev[wDevID];
+
+    FIXME("\n");
+   
+    /* updates current notify list */
+    /* if resetting, remove all wave headers and notify client that all headers were completed */
+    wodHelper_NotifyCompletions(wwo, TRUE);
     
-    return wodHelper_Reset(&WOutDev[wDevID], TRUE);
+    pthread_mutex_lock(&wwo->lock);
+    
+    wwo->lpPlayPtr = wwo->lpQueuePtr = wwo->lpLoopPtr = NULL;
+    wwo->state = WINE_WS_STOPPED;
+    wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
+
+    wwo->dwPartialOffset = 0;        /* Clear partial wavehdr */
+
+    pthread_mutex_unlock(&wwo->lock);
+
+    status = AudioOutputUnitStart(wwo->audioUnit);
+
+    if (status) {
+        ERR( "AudioOutputUnitStart return %c%c%c%c\n",
+             (char) (status >> 24), (char) (status >> 16), (char) (status >> 8), (char) status);
+        return MMSYSERR_ERROR; /* FIXME return an error based on the OSStatus */
+    }
+
+    return MMSYSERR_NOERROR;
 }
 
 /**************************************************************************


More information about the wine-patches mailing list