From 21c45016034b48fc93356195993726d91153e7cf Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Tue, 16 Oct 2012 14:06:26 +0200 Subject: [PATCH] dsound: Fix IDirectSoundCaptureBuffer Start/Stop, with tests. --- dlls/dsound/capture.c | 6 ++++-- dlls/dsound/tests/capture.c | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index 5336b592bf9..1b004e6ada3 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -493,13 +493,14 @@ static HRESULT WINAPI IDirectSoundCaptureBufferImpl_Start(IDirectSoundCaptureBuf EnterCriticalSection(&(This->device->lock)); - This->flags = dwFlags; - TRACE("old This->device->state=%s\n",captureStateString[This->device->state]); if (This->device->state == STATE_STOPPED) This->device->state = STATE_STARTING; else if (This->device->state == STATE_STOPPING) This->device->state = STATE_CAPTURING; + else + goto out; TRACE("new This->device->state=%s\n",captureStateString[This->device->state]); + This->flags = dwFlags; if (This->device->buffer) FillMemory(This->device->buffer, This->device->buflen, (This->device->pwfx->wBitsPerSample == 8) ? 128 : 0); @@ -511,6 +512,7 @@ static HRESULT WINAPI IDirectSoundCaptureBufferImpl_Start(IDirectSoundCaptureBuf return hres; } +out: LeaveCriticalSection(&This->device->lock); TRACE("returning DS_OK\n"); diff --git a/dlls/dsound/tests/capture.c b/dlls/dsound/tests/capture.c index ba52818a1d3..2afd5222203 100644 --- a/dlls/dsound/tests/capture.c +++ b/dlls/dsound/tests/capture.c @@ -394,15 +394,18 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, ok(ref==0,"IDirectSoundNotify_Release(): has %d references, should have " "0\n",ref); - if (record) { - rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING); - ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc); + rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc); + + rc=IDirectSoundCaptureBuffer_Start(dscbo,0); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc); - rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status); - ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc); - ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING), - "GetStatus: bad status: %x\n",status); + rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc); + ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING), + "GetStatus: bad status: %x\n",status); + if (record) { /* wait for the notifications */ for (i = 0; i < (NOTIFICATIONS * 2); i++) { rc=WaitForMultipleObjects(NOTIFICATIONS,state.event,FALSE,3000); @@ -417,9 +420,12 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, break; } - rc=IDirectSoundCaptureBuffer_Stop(dscbo); - ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc); } + rc=IDirectSoundCaptureBuffer_Stop(dscbo); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc); + + rc=IDirectSoundCaptureBuffer_Stop(dscbo); + ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc); } static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, -- 2.11.4.GIT