Commit 8a1d4d1e authored by Chris Robinson's avatar Chris Robinson Committed by Alexandre Julliard

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

parent dab3825b
...@@ -132,11 +132,20 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface) ...@@ -132,11 +132,20 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
TRACE("nBlockAlign = %d\n", format->nBlockAlign); TRACE("nBlockAlign = %d\n", format->nBlockAlign);
TRACE("wBitsPerSample = %d\n", format->wBitsPerSample); TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
TRACE("cbSize = %d\n", format->cbSize); 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); hr = DirectSoundCreate(NULL, &This->dsound, NULL);
if (FAILED(hr)) { if (FAILED(hr)) {
ERR("Cannot create Direct Sound object\n"); ERR("Cannot create Direct Sound object\n");
return hr; goto getout;
} }
wav_fmt = *format; wav_fmt = *format;
...@@ -151,7 +160,7 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface) ...@@ -151,7 +160,7 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
if (FAILED(hr)) { if (FAILED(hr)) {
ERR("Can't create sound buffer !\n"); ERR("Can't create sound buffer !\n");
IDirectSound_Release(This->dsound); IDirectSound_Release(This->dsound);
return hr; goto getout;
} }
hr = IDirectSoundBuffer_SetVolume(This->dsbuffer, This->volume); hr = IDirectSoundBuffer_SetVolume(This->dsbuffer, This->volume);
...@@ -167,11 +176,13 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface) ...@@ -167,11 +176,13 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
ERR("Can't start sound buffer (%x)!\n", hr); ERR("Can't start sound buffer (%x)!\n", hr);
IDirectSoundBuffer_Release(This->dsbuffer); IDirectSoundBuffer_Release(This->dsbuffer);
IDirectSound_Release(This->dsound); IDirectSound_Release(This->dsound);
return hr; goto getout;
} }
This->write_pos = 0; This->write_pos = 0;
getout:
LeaveCriticalSection(&This->csFilter);
return hr; return hr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment