[11/11] wineesd.drv: Write the data in small chunks in an attempt to pleas the Unix socket gods.

Francois Gouget fgouget at codeweavers.com
Sat Mar 28 06:17:31 CDT 2009


---

This patch is not meant to be committed either.

It is another attempt to fix the problem described in the previous 
patch. It seemed to work for a while but in fact trying to write smaller 
chunks only delays the onset of the issue a little bit.

So I'm posting it in case further investigation reveals the need to test 
with smaller chunks.

 dlls/wineesd.drv/audio.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/dlls/wineesd.drv/audio.c b/dlls/wineesd.drv/audio.c
index b56dea2..6a55aab 100644
--- a/dlls/wineesd.drv/audio.c
+++ b/dlls/wineesd.drv/audio.c
@@ -801,13 +801,16 @@ static DWORD wodPlayer_NotifyWait(const WINE_WAVEOUT* wwo, LPWAVEHDR lpWaveHdr)
  */
 static int wodPlayer_WriteMaxFrags(WINE_WAVEOUT* wwo)
 {
-    DWORD dwLength = wwo->lpPlayPtr->dwBufferLength - wwo->dwPartialOffset;
+    DWORD dwLength, now;
     int written;
-    DWORD now;
 
     TRACE("Writing wavehdr %p.%u[%u]\n",
           wwo->lpPlayPtr, wwo->dwPartialOffset, wwo->lpPlayPtr->dwBufferLength);
 
+    /* Write the data in small chunks in an attempt to please the Unix socket
+     * gods.
+     */
+    dwLength = min(4096, wwo->lpPlayPtr->dwBufferLength - wwo->dwPartialOffset);
     written = write(wwo->stream_fd, wwo->lpPlayPtr->lpData + wwo->dwPartialOffset, dwLength);
     if (written <= 0)
     {
@@ -820,16 +823,16 @@ static int wodPlayer_WriteMaxFrags(WINE_WAVEOUT* wwo)
 
     wwo->dwLastWrite = now;
     wwo->dwWrittenTotal += written; /* update stats on this wave device */
-    if (written == dwLength)
+    /* Remove the amount written and wait a bit before trying to write more */
+    wwo->dwPartialOffset += written;
+    if (wwo->dwPartialOffset == wwo->lpPlayPtr->dwBufferLength)
     {
         /* We're done with this wavehdr, skip to the next one */
         wodPlayer_PlayPtrNext(wwo);
         return 1;
     }
 
-    /* Remove the amount written and wait a bit before trying to write more */
-    wwo->dwPartialOffset += written;
-    return 0;
+    return (written < dwLength ? 0 : 1);
 }
 
 
-- 
1.6.2



More information about the wine-patches mailing list