Add tests to check DirectSoundCapture creation.
Fix dsound/capture.c to pass tests.
This commit is contained in:
parent
d73dad6630
commit
4c315db1a6
|
@ -91,7 +91,6 @@ HRESULT WINAPI IDirectSoundCaptureImpl_Create(
|
|||
}
|
||||
|
||||
HRESULT WINAPI DSOUND_CaptureCreate(
|
||||
|
||||
LPDIRECTSOUNDCAPTURE *ppDSC,
|
||||
IUnknown *pUnkOuter)
|
||||
{
|
||||
|
@ -457,7 +456,7 @@ IDirectSoundCaptureImpl_QueryInterface(
|
|||
REFIID riid,
|
||||
LPVOID* ppobj )
|
||||
{
|
||||
DirectSoundCaptureDevice *This = ((IDirectSoundCaptureImpl *)iface)->device;
|
||||
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
||||
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
||||
|
||||
if (ppobj == NULL) {
|
||||
|
@ -467,16 +466,18 @@ IDirectSoundCaptureImpl_QueryInterface(
|
|||
|
||||
*ppobj = NULL;
|
||||
|
||||
if (This->driver) {
|
||||
HRESULT hres;
|
||||
hres = IDsCaptureDriver_QueryInterface(This->driver, riid, ppobj);
|
||||
if (hres != DS_OK)
|
||||
WARN("IDsCaptureDriver_QueryInterface failed\n");
|
||||
return hres;
|
||||
if (IsEqualIID(riid, &IID_IUnknown)) {
|
||||
IDirectSoundCapture_AddRef((LPDIRECTSOUNDCAPTURE)This);
|
||||
*ppobj = This;
|
||||
return DS_OK;
|
||||
} else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) {
|
||||
IDirectSoundCapture_AddRef((LPDIRECTSOUNDCAPTURE)This);
|
||||
*ppobj = This;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
WARN("unsupported riid: %s\n", debugstr_guid(riid));
|
||||
return E_FAIL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI
|
||||
|
@ -492,7 +493,6 @@ static ULONG DirectSoundCaptureDevice_Release(
|
|||
DirectSoundCaptureDevice * device)
|
||||
{
|
||||
ULONG ref;
|
||||
|
||||
TRACE("(%p) ref was %lu\n", device, device->ref);
|
||||
|
||||
device->ref--;
|
||||
|
@ -590,6 +590,11 @@ IDirectSoundCaptureImpl_GetCaps(
|
|||
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
||||
TRACE("(%p,%p)\n",This,lpDSCCaps);
|
||||
|
||||
if (This->device == NULL) {
|
||||
WARN("not initialized\n");
|
||||
return DSERR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
if (lpDSCCaps== NULL) {
|
||||
WARN("invalid parameter: lpDSCCaps== NULL\n");
|
||||
return DSERR_INVALIDPARAM;
|
||||
|
@ -601,11 +606,6 @@ IDirectSoundCaptureImpl_GetCaps(
|
|||
return DSERR_INVALIDPARAM;
|
||||
}
|
||||
|
||||
if ( !(This->device) ) {
|
||||
WARN("not initialized\n");
|
||||
return DSERR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
lpDSCCaps->dwFlags = This->device->drvcaps.dwFlags;
|
||||
lpDSCCaps->dwFormats = This->device->drvcaps.dwFormats;
|
||||
lpDSCCaps->dwChannels = This->device->drvcaps.dwChannels;
|
||||
|
@ -1771,10 +1771,7 @@ DSCCF_CreateInstance(
|
|||
*ppobj = NULL;
|
||||
|
||||
if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) )
|
||||
return DSOUND_CaptureCreate((LPDIRECTSOUNDCAPTURE*)ppobj,pOuter);
|
||||
|
||||
if ( IsEqualGUID( &IID_IDirectSoundCapture8, riid ) )
|
||||
return DSOUND_CaptureCreate8((LPDIRECTSOUNDCAPTURE8*)ppobj,pOuter);
|
||||
return DSOUND_CaptureCreate8((LPDIRECTSOUNDCAPTURE*)ppobj,pOuter);
|
||||
|
||||
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
|
||||
return E_NOINTERFACE;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "dsound.h"
|
||||
#include "mmreg.h"
|
||||
#include "dxerr8.h"
|
||||
#include "dsconf.h"
|
||||
|
||||
#include "dsound_test.h"
|
||||
|
||||
|
@ -101,6 +102,163 @@ static char * format_string(WAVEFORMATEX* wfx)
|
|||
return str;
|
||||
}
|
||||
|
||||
static void IDirectSoundCapture_test(LPDIRECTSOUNDCAPTURE dsco,
|
||||
BOOL initialized, LPCGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
DSCCAPS dsccaps;
|
||||
int ref;
|
||||
IUnknown * unknown;
|
||||
IDirectSoundCapture * dsc;
|
||||
|
||||
/* Try to Query for objects */
|
||||
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IUnknown,
|
||||
(LPVOID*)&unknown);
|
||||
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IUnknown) "
|
||||
"failed: %s\n", DXGetErrorString8(rc));
|
||||
if (rc==DS_OK)
|
||||
IDirectSoundCapture_Release(unknown);
|
||||
|
||||
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IDirectSoundCapture,
|
||||
(LPVOID*)&dsc);
|
||||
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IDirectSoundCapture) "
|
||||
"failed: %s\n", DXGetErrorString8(rc));
|
||||
if (rc==DS_OK)
|
||||
IDirectSoundCapture_Release(dsc);
|
||||
|
||||
if (initialized == FALSE) {
|
||||
/* try unitialized object */
|
||||
rc=IDirectSoundCapture_GetCaps(dsco,0);
|
||||
ok(rc==DSERR_UNINITIALIZED, "IDirectSoundCapture_GetCaps(NULL) "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
|
||||
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
|
||||
ok(rc==DSERR_UNINITIALIZED,"IDirectSoundCapture_GetCaps() "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
|
||||
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"IDirectSoundCapture_Initialize() failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (rc==DSERR_NODRIVER) {
|
||||
trace(" No Driver\n");
|
||||
goto EXIT;
|
||||
} else if (rc==E_FAIL) {
|
||||
trace(" No Device\n");
|
||||
goto EXIT;
|
||||
} else if (rc==DSERR_ALLOCATED) {
|
||||
trace(" Already In Use\n");
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
|
||||
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSoundCapture_Initialize() "
|
||||
"should have returned DSERR_ALREADYINITIALIZED: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
|
||||
/* DSOUND: Error: Invalid caps buffer */
|
||||
rc=IDirectSoundCapture_GetCaps(dsco, 0);
|
||||
ok(rc==DSERR_INVALIDPARAM, "IDirectSoundCapture_GetCaps(NULL) "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
|
||||
ZeroMemory(&dsccaps, sizeof(dsccaps));
|
||||
|
||||
/* DSOUND: Error: Invalid caps buffer */
|
||||
rc=IDirectSound_GetCaps(dsco, &dsccaps);
|
||||
ok(rc==DSERR_INVALIDPARAM, "IDirectSound_GetCaps() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
|
||||
dsccaps.dwSize=sizeof(dsccaps);
|
||||
|
||||
/* DSOUND: Running on a certified driver */
|
||||
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
|
||||
ok(rc==DS_OK, "IDirectSoundCapture_GetCaps() failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
|
||||
EXIT:
|
||||
ref=IDirectSoundCapture_Release(dsco);
|
||||
ok(ref==0, "IDirectSoundCapture_Release() has %d references, "
|
||||
"should have 0\n", ref);
|
||||
}
|
||||
|
||||
static void IDirectSoundCapture_tests()
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUNDCAPTURE dsco=NULL;
|
||||
|
||||
trace("Testing IDirectSoundCapture\n");
|
||||
|
||||
/* try the COM class factory method of creation with no device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSoundCapture, (void**)&dsco);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (dsco)
|
||||
IDirectSoundCapture_test(dsco, FALSE, NULL);
|
||||
|
||||
/* try the COM class factory method of creation with default capture
|
||||
* device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSoundCapture, (void**)&dsco);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (dsco)
|
||||
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultCapture);
|
||||
|
||||
/* try the COM class factory method of creation with default voice
|
||||
* capture device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSoundCapture, (void**)&dsco);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (dsco)
|
||||
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultVoiceCapture);
|
||||
|
||||
/* try the COM class factory method of creation with a bad
|
||||
* IID specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&CLSID_DirectSoundPrivate, (void**)&dsco);
|
||||
ok(rc==E_NOINTERFACE,
|
||||
"CoCreateInstance(CLSID_DirectSoundCapture,CLSID_DirectSoundPrivate) "
|
||||
"should have failed: %s\n",DXGetErrorString8(rc));
|
||||
|
||||
/* try with no device specified */
|
||||
rc=DirectSoundCaptureCreate(NULL,&dsco,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCaptureCreate(NULL) failed: %s\n",DXGetErrorString8(rc));
|
||||
if (rc==S_OK && dsco)
|
||||
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
||||
|
||||
/* try with default capture device specified */
|
||||
rc=DirectSoundCaptureCreate(&DSDEVID_DefaultCapture,&dsco,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCaptureCreate(DSDEVID_DefaultCapture) failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (rc==DS_OK && dsco)
|
||||
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
||||
|
||||
/* try with default voice capture device specified */
|
||||
rc=DirectSoundCaptureCreate(&DSDEVID_DefaultVoiceCapture,&dsco,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCaptureCreate(DSDEVID_DefaultVoiceCapture) failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (rc==DS_OK && dsco)
|
||||
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
||||
|
||||
/* try with a bad device specified */
|
||||
rc=DirectSoundCaptureCreate(&DSDEVID_DefaultVoicePlayback,&dsco,NULL);
|
||||
ok(rc==DSERR_NODRIVER,
|
||||
"DirectSoundCaptureCreate(DSDEVID_DefaultVoicePlatback) "
|
||||
"should have failed: %s\n",DXGetErrorString8(rc));
|
||||
if (rc==DS_OK && dsco)
|
||||
IDirectSoundCapture_Release(dsco);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char* wave;
|
||||
DWORD wave_len;
|
||||
|
@ -552,6 +710,7 @@ START_TEST(capture)
|
|||
return;
|
||||
}
|
||||
|
||||
IDirectSoundCapture_tests();
|
||||
capture_tests();
|
||||
|
||||
CoUninitialize();
|
||||
|
|
Loading…
Reference in New Issue