[07/16] winecoreaudio: Eliminate unnecessary variable, unreachable code, unused retval.

Ken Thomases ken at codeweavers.com
Thu Dec 21 03:48:52 CST 2006


In wodHelper_PlayPtrNext, the lpWaveHdr local variable just serves as a shadow
of wwo->lpPlayPtr.  The shadowing just made the code more complex, since the
original needed to be updated anyway.

Also, wwo->lpPlayPtr will never be NULL when wodHelper_PlayPtrNext is called,
so no need to test it and bail early.

Lastly, the caller never uses the return value.  So, make it a void function.
---
  dlls/winmm/winecoreaudio/audio.c |   22 +++++-----------------
  1 files changed, 5 insertions(+), 17 deletions(-)
-------------- next part --------------
diff --git a/dlls/winmm/winecoreaudio/audio.c b/dlls/winmm/winecoreaudio/audio.c
index ab76762..09bd2d3 100644
--- a/dlls/winmm/winecoreaudio/audio.c
+++ b/dlls/winmm/winecoreaudio/audio.c
@@ -179,7 +179,7 @@ static WINE_WAVEOUT WOutDev   [MAX_WAVEO
 
 static CFMessagePortRef Port_SendToMessageThread;
 
-static LPWAVEHDR wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo);
+static void wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo);
 static DWORD wodHelper_NotifyCompletions(WINE_WAVEOUT* wwo, BOOL force);
 
 extern int AudioUnit_CreateDefaultAudioUnit(void *wwo, AudioUnit *au);
@@ -888,22 +888,14 @@ static void wodHelper_CheckForLoopBegin(
 * Advance the play pointer to the next waveheader, looping if required.
 * Call from AudioUnit IO thread can't use Wine debug channels.
 */
-static LPWAVEHDR wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo)
+static void wodHelper_PlayPtrNext(WINE_WAVEOUT* wwo)
 {
-    LPWAVEHDR lpWaveHdr;
     BOOL didLoopBack = FALSE;
 
     pthread_mutex_lock(&wwo->lock);
     
-    lpWaveHdr = wwo->lpPlayPtr;
-    if (!lpWaveHdr)
-    {
-        pthread_mutex_unlock(&wwo->lock);
-        return NULL;
-    }
-
     wwo->dwPartialOffset = 0;
-    if ((lpWaveHdr->dwFlags & WHDR_ENDLOOP) && wwo->lpLoopPtr)
+    if ((wwo->lpPlayPtr->dwFlags & WHDR_ENDLOOP) && wwo->lpLoopPtr)
     {
         /* We're at the end of a loop, loop if required */
         if (wwo->dwLoops > 1)
@@ -921,11 +913,9 @@ static LPWAVEHDR wodHelper_PlayPtrNext(W
     if (!didLoopBack)
     {
         /* We didn't loop back.  Advance to the next wave header */
-        lpWaveHdr = lpWaveHdr->lpNext;
+        wwo->lpPlayPtr = wwo->lpPlayPtr->lpNext;
 
-        wwo->lpPlayPtr = lpWaveHdr;
-
-        if (!lpWaveHdr)
+        if (!wwo->lpPlayPtr)
         {
             OSStatus status;
             wwo->state = WINE_WS_STOPPED;
@@ -939,8 +929,6 @@ static LPWAVEHDR wodHelper_PlayPtrNext(W
     }
     
     pthread_mutex_unlock(&wwo->lock);
-    
-    return lpWaveHdr;
 }
 
 /* if force is TRUE then notify the client that all the headers were completed


More information about the wine-patches mailing list