Skip to content
Snippets Groups Projects
Commit 92b48ba8 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard
Browse files

Fixed deadlock in capture callback.

Fixed capture test to check all notifications.
Added better debug messages to capture test.
parent 01c5ef37
No related branches found
No related tags found
No related merge requests found
......@@ -320,18 +320,14 @@ DSOUND_capture_callback(
msg == MM_WIM_DATA ? "MM_WIM_DATA" : "UNKNOWN",dwUser,dw1,dw2,GetTickCount());
if (msg == MM_WIM_DATA) {
LPWAVEHDR pHdr = (LPWAVEHDR)dw1;
EnterCriticalSection( &(This->lock) );
TRACE("DirectSoundCapture msg=MM_WIM_DATA, old This->state=%s, old This->index=%d\n",
captureStateString[This->state],This->index);
if (This->state != STATE_STOPPED) {
int index = This->index;
if (This->state == STATE_STARTING) {
MMTIME mtime;
mtime.wType = TIME_BYTES;
waveInGetPosition(This->hwi, &mtime, sizeof(mtime));
TRACE("mtime.u.cb=%ld,This->buflen=%ld\n", mtime.u.cb, This->buflen);
mtime.u.cb = mtime.u.cb % This->buflen;
This->read_position = mtime.u.cb;
This->read_position = pHdr->dwBytesRecorded;
This->state = STATE_CAPTURING;
}
waveInUnprepareHeader(hwi,&(This->pwave[This->index]),sizeof(WAVEHDR));
......@@ -1376,6 +1372,7 @@ IDirectSoundCaptureBufferImpl_Start(
This->notifies[c].dwOffset -
This->notifies[c-1].dwOffset;
}
ipDSC->pwave[c].dwBytesRecorded = 0;
ipDSC->pwave[c].dwUser = (DWORD)ipDSC;
ipDSC->pwave[c].dwFlags = 0;
ipDSC->pwave[c].dwLoops = 0;
......@@ -1411,6 +1408,7 @@ IDirectSoundCaptureBufferImpl_Start(
ipDSC->pwave[0].lpData = ipDSC->buffer;
ipDSC->pwave[0].dwBufferLength = ipDSC->buflen;
ipDSC->pwave[0].dwBytesRecorded = 0;
ipDSC->pwave[0].dwUser = (DWORD)ipDSC;
ipDSC->pwave[0].dwFlags = 0;
ipDSC->pwave[0].dwLoops = 0;
......
......@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = dsound.dll
IMPORTS = dsound user32 kernel32
EXTRALIBS = -ldxguid -luuid
EXTRALIBS = -ldxguid -luuid -ldxerr9
CTESTS = \
capture.c \
......
......@@ -32,6 +32,7 @@
#include "wingdi.h"
#include "dsound.h"
#include "mmreg.h"
#include "dxerr9.h"
static const unsigned int formats[][3]={
{ 8000, 8, 1},
......@@ -115,17 +116,17 @@ static int capture_buffer_service(capture_state_t* state)
DWORD capture_pos,read_pos;
rc=IDirectSoundCaptureBuffer_GetCurrentPosition(state->dscbo,&capture_pos,&read_pos);
ok(rc==DS_OK,"GetCurrentPosition failed: 0x%lx\n",rc);
ok(rc==DS_OK,"GetCurrentPosition failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
return 0;
rc=IDirectSoundCaptureBuffer_Lock(state->dscbo,state->offset,state->size,&ptr1,&len1,&ptr2,&len2,0);
ok(rc==DS_OK,"Lock failed: 0x%lx\n",rc);
ok(rc==DS_OK,"Lock failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
return 0;
rc=IDirectSoundCaptureBuffer_Unlock(state->dscbo,ptr1,len1,ptr2,len2);
ok(rc==DS_OK,"Unlock failed: 0x%lx\n",rc);
ok(rc==DS_OK,"Unlock failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
return 0;
......@@ -146,16 +147,16 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
/* Private dsound.dll: Error: Invalid caps pointer */
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,0);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
/* Private dsound.dll: Error: Invalid caps pointer */
dscbcaps.dwSize=0;
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
dscbcaps.dwSize=sizeof(dscbcaps);
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
ok(rc==DS_OK,"GetCaps failed: 0x%lx\n",rc);
ok(rc==DS_OK,"GetCaps failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
trace(" Caps: size = %ld flags=0x%08lx buffer size=%ld\n",
dscbcaps.dwSize,dscbcaps.dwFlags,dscbcaps.dwBufferBytes);
......@@ -165,16 +166,16 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
/* Private dsound.dll: Error: Either pwfxFormat or pdwSizeWritten must be non-NULL */
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,NULL);
ok(rc==DSERR_INVALIDPARAM,
"GetFormat should have returned an error: rc=0x%lx\n",rc);
"GetFormat should have returned an error: rc=0x%lx(%s)\n",rc,DXGetErrorString9(rc));
size=0;
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,&size);
ok(rc==DS_OK && size!=0,
"GetFormat should have returned the needed size: rc=0x%lx size=%ld\n",
rc,size);
"GetFormat should have returned the needed size: rc=0x%lx(%s) size=%ld\n",
rc,DXGetErrorString9(rc),size);
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,&wfx,sizeof(wfx),NULL);
ok(rc==DS_OK,"GetFormat failed: 0x%lx\n",rc);
ok(rc==DS_OK,"GetFormat failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
trace(" tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
......@@ -183,10 +184,10 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
/* Private dsound.dll: Error: Invalid status pointer */
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,0);
ok(rc==DSERR_INVALIDPARAM,"GetStatus should have failed: 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"GetStatus should have failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
ok(rc==DS_OK,"GetStatus failed: 0x%lx\n",rc);
ok(rc==DS_OK,"GetStatus failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
trace(" status=0x%04lx\n",status);
}
......@@ -200,7 +201,7 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
state.size = dscbcaps.dwBufferBytes / NOTIFICATIONS;
rc=IDirectSoundCaptureBuffer_QueryInterface(dscbo,&IID_IDirectSoundNotify,(void **)&(state.notify));
ok((rc==DS_OK)&&(state.notify!=NULL),"QueryInterface failed: 0x%lx\n",rc);
ok((rc==DS_OK)&&(state.notify!=NULL),"QueryInterface failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
return;
......@@ -210,23 +211,23 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
}
rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS,state.posnotify);
ok(rc==DS_OK,"SetNotificationPositions failed: 0x%lx\n",rc);
ok(rc==DS_OK,"SetNotificationPositions failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
return;
rc=IDirectSoundNotify_Release(state.notify);
ok(rc==0,"Release: 0x%lx\n",rc);
ok(rc==0,"Release: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=0)
return;
if (record) {
rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING);
ok(rc==DS_OK,"Start: 0x%lx\n",rc);
ok(rc==DS_OK,"Start: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
return;
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
ok(rc==DS_OK,"GetStatus failed: 0x%lx\n",rc);
ok(rc==DS_OK,"GetStatus failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING),
"GetStatus: bad status: %lx\n",status);
if (rc!=DS_OK)
......@@ -239,14 +240,13 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
if (rc!=(WAIT_OBJECT_0+(i%NOTIFICATIONS))) {
ok((rc==WAIT_TIMEOUT)||(rc==WAIT_FAILED),"Wrong notification: should be %d, got %ld\n",
i%NOTIFICATIONS,rc-WAIT_OBJECT_0);
} else
break;
}
if (!capture_buffer_service(&state))
break;
}
rc=IDirectSoundCaptureBuffer_Stop(dscbo);
ok(rc==DS_OK,"Stop: 0x%lx\n",rc);
ok(rc==DS_OK,"Stop: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
return;
}
......@@ -266,29 +266,29 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
/* Private dsound.dll: Error: Invalid interface buffer */
trace("Testing %s - %s\n",lpcstrDescription,lpcstrModule);
rc=DirectSoundCaptureCreate(lpGuid,NULL,NULL);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCaptureCreate didn't fail: 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCaptureCreate didn't fail: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
ref=IDirectSoundCapture_Release(dsco);
ok(ref==0,"IDirectSoundCapture_Release has %d references, should have 0\n",ref);
}
rc=DirectSoundCaptureCreate(lpGuid,&dsco,NULL);
ok((rc==DS_OK)||(rc==DSERR_NODRIVER),"DirectSoundCaptureCreate failed: 0x%lx\n",rc);
ok((rc==DS_OK)||(rc==DSERR_NODRIVER),"DirectSoundCaptureCreate failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc!=DS_OK)
goto EXIT;
/* Private dsound.dll: Error: Invalid caps buffer */
rc=IDirectSoundCapture_GetCaps(dsco,NULL);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
/* Private dsound.dll: Error: Invalid caps buffer */
dsccaps.dwSize=0;
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
dsccaps.dwSize=sizeof(dsccaps);
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
ok(rc==DS_OK,"GetCaps failed: 0x%lx\n",rc);
ok(rc==DS_OK,"GetCaps failed: 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
trace(" DirectSoundCapture Caps: size=%ld flags=0x%08lx formats=%05lx channels=%ld\n",
dsccaps.dwSize,dsccaps.dwFlags,dsccaps.dwFormats,dsccaps.dwChannels);
......@@ -303,7 +303,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=NULL;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release has %d references, should have 0\n",ref);
......@@ -318,7 +318,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=NULL;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release has %d references, should have 0\n",ref);
......@@ -334,7 +334,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release has %d references, should have 0\n",ref);
......@@ -350,7 +350,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx\n",rc);
ok(rc==DSERR_INVALIDPARAM,"CreateCaptureBuffer should have failed to create a capture buffer 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
ref=IDirectSoundCaptureBuffer_Release(dscbo);
ok(ref==0,"IDirectSoundCaptureBuffer_Release has %d references, should have 0\n",ref);
......@@ -367,7 +367,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.lpwfxFormat=&wfx;
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok((rc==DS_OK)&&(dscbo!=NULL),"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc);
ok((rc==DS_OK)&&(dscbo!=NULL),"CreateCaptureBuffer failed to create a capture buffer 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if (rc==DS_OK) {
test_capture_buffer(dsco, dscbo, winetest_interactive);
ref=IDirectSoundCaptureBuffer_Release(dscbo);
......@@ -386,7 +386,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.lpwfxFormat=&wfx;
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok((rc==DS_OK)&&(dscbo!=NULL),"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc);
ok((rc==DS_OK)&&(dscbo!=NULL),"CreateCaptureBuffer failed to create a capture buffer 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
if ((rc==DS_OK)&&(dscbo!=NULL)) {
test_capture_buffer(dsco, dscbo, winetest_interactive);
ref=IDirectSoundCaptureBuffer_Release(dscbo);
......@@ -405,7 +405,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.lpwfxFormat=&wfx;
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc!=DS_OK,"CreateCaptureBuffer should have failed at 2 MHz 0x%lx\n",rc);
ok(rc!=DS_OK,"CreateCaptureBuffer should have failed at 2 MHz 0x%lx(%s)\n",rc,DXGetErrorString9(rc));
#endif
EXIT:
......@@ -421,7 +421,7 @@ static void capture_tests()
{
HRESULT rc;
rc=DirectSoundCaptureEnumerateA(&dscenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundCaptureEnumerate failed: %ld\n",rc);
ok(rc==DS_OK,"DirectSoundCaptureEnumerate failed: 0x%08lx(%s)\n",rc,DXGetErrorString9(rc));
}
START_TEST(capture)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment