From: Sven Baars sven.wine@gmail.com
Signed-off-by: Sven Baars sven.wine@gmail.com Signed-off-by: Andrew Eikum aeikum@codeweavers.com ---
v2: Change the subject. I like this patch for code cleanup, but I don't think it fixed a real deadlock. The locks being interleaved are the same lock.
dlls/winmm/waveform.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c index 11a5cad601b..b08768577bb 100644 --- a/dlls/winmm/waveform.c +++ b/dlls/winmm/waveform.c @@ -1966,27 +1966,20 @@ static MMRESULT WINMM_BeginPlaying(WINMM_Device *device) return MMSYSERR_NOERROR; }
-static LRESULT WINMM_Pause(HWAVE hwave) +static LRESULT WINMM_Pause(WINMM_Device *device) { - WINMM_Device *device = WINMM_GetDeviceFromHWAVE(hwave); HRESULT hr;
- TRACE("(%p)\n", hwave); - - if(!WINMM_ValidateAndLock(device)) - return MMSYSERR_INVALHANDLE; + TRACE("(%p)\n", device->handle);
hr = IAudioClient_Stop(device->client); if(FAILED(hr)){ - LeaveCriticalSection(&device->lock); WARN("Stop failed: %08x\n", hr); return MMSYSERR_ERROR; }
device->stopped = FALSE;
- LeaveCriticalSection(&device->lock); - return MMSYSERR_NOERROR; }
@@ -2939,9 +2932,21 @@ UINT WINAPI waveOutBreakLoop(HWAVEOUT hWaveOut) */ UINT WINAPI waveOutPause(HWAVEOUT hWaveOut) { + WINMM_Device *device; + MMRESULT mr; + TRACE("(%p)\n", hWaveOut);
- return WINMM_Pause((HWAVE)hWaveOut); + device = WINMM_GetDeviceFromHWAVE((HWAVE)hWaveOut); + + if(!WINMM_ValidateAndLock(device)) + return MMSYSERR_INVALHANDLE; + + mr = WINMM_Pause(device); + + LeaveCriticalSection(&device->lock); + + return mr; }
/************************************************************************** @@ -3573,7 +3578,7 @@ UINT WINAPI waveInStop(HWAVEIN hWaveIn) if(!WINMM_ValidateAndLock(device)) return MMSYSERR_INVALHANDLE;
- hr = WINMM_Pause((HWAVE)hWaveIn); + hr = WINMM_Pause(device); if(FAILED(hr)){ LeaveCriticalSection(&device->lock); return MMSYSERR_ERROR;