Chris Robinson : quartz: Protect DSound buffer creation with a critical section lock.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Mar 28 06:41:43 CDT 2007


Module: wine
Branch: master
Commit: 8a1d4d1e4c6dca0b3be6c0784861aed4c6451679
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8a1d4d1e4c6dca0b3be6c0784861aed4c6451679

Author: Chris Robinson <chris.kcat at gmail.com>
Date:   Tue Mar 27 02:45:15 2007 -0700

quartz: Protect DSound buffer creation with a critical section lock.

---

 dlls/quartz/dsoundrender.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c
index 80f7257..259a25b 100644
--- a/dlls/quartz/dsoundrender.c
+++ b/dlls/quartz/dsoundrender.c
@@ -132,11 +132,20 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
     TRACE("nBlockAlign = %d\n", format->nBlockAlign);
     TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
     TRACE("cbSize = %d\n", format->cbSize);
-    
+
+    /* Lock the critical section to make sure we're still marked to play while
+       setting up the playback buffer */
+    EnterCriticalSection(&This->csFilter);
+
+    if (This->state != State_Running) {
+        hr = VFW_E_WRONG_STATE;
+        goto getout;
+    }
+
     hr = DirectSoundCreate(NULL, &This->dsound, NULL);
     if (FAILED(hr)) {
 	ERR("Cannot create Direct Sound object\n");
-	return hr;
+	goto getout;
     }
 
     wav_fmt = *format;
@@ -151,7 +160,7 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
     if (FAILED(hr)) {
         ERR("Can't create sound buffer !\n");
         IDirectSound_Release(This->dsound);
-        return hr;
+        goto getout;
     }
 
     hr = IDirectSoundBuffer_SetVolume(This->dsbuffer, This->volume);
@@ -167,11 +176,13 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
         ERR("Can't start sound buffer (%x)!\n", hr);
         IDirectSoundBuffer_Release(This->dsbuffer);
         IDirectSound_Release(This->dsound);
-        return hr;
+        goto getout;
     }
 
     This->write_pos = 0;
-    
+
+getout:
+    LeaveCriticalSection(&This->csFilter);
     return hr;
 }
 




More information about the wine-cvs mailing list