quartz: Protect DSound buffer creation with a critical section lock
Chris Robinson
chris.kcat at gmail.com
Tue Mar 27 04:47:53 CDT 2007
-------------- next part --------------
From 58b4367fca41ed64cbec4712a5b576a6996b77dd Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat at gmail.com>
Date: Tue, 27 Mar 2007 02:45:15 -0700
Subject: [PATCH] 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;
}
--
1.4.4.4
More information about the wine-patches
mailing list