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(
|
HRESULT WINAPI DSOUND_CaptureCreate(
|
||||||
|
|
||||||
LPDIRECTSOUNDCAPTURE *ppDSC,
|
LPDIRECTSOUNDCAPTURE *ppDSC,
|
||||||
IUnknown *pUnkOuter)
|
IUnknown *pUnkOuter)
|
||||||
{
|
{
|
||||||
|
@ -254,7 +253,7 @@ static HRESULT DirectSoundCaptureDevice_Create(
|
||||||
{
|
{
|
||||||
DirectSoundCaptureDevice * device;
|
DirectSoundCaptureDevice * device;
|
||||||
TRACE("(%p)\n", ppDevice);
|
TRACE("(%p)\n", ppDevice);
|
||||||
|
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
device = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DirectSoundCaptureDevice));
|
device = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DirectSoundCaptureDevice));
|
||||||
|
|
||||||
|
@ -457,7 +456,7 @@ IDirectSoundCaptureImpl_QueryInterface(
|
||||||
REFIID riid,
|
REFIID riid,
|
||||||
LPVOID* ppobj )
|
LPVOID* ppobj )
|
||||||
{
|
{
|
||||||
DirectSoundCaptureDevice *This = ((IDirectSoundCaptureImpl *)iface)->device;
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
||||||
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
|
||||||
|
|
||||||
if (ppobj == NULL) {
|
if (ppobj == NULL) {
|
||||||
|
@ -467,16 +466,18 @@ IDirectSoundCaptureImpl_QueryInterface(
|
||||||
|
|
||||||
*ppobj = NULL;
|
*ppobj = NULL;
|
||||||
|
|
||||||
if (This->driver) {
|
if (IsEqualIID(riid, &IID_IUnknown)) {
|
||||||
HRESULT hres;
|
IDirectSoundCapture_AddRef((LPDIRECTSOUNDCAPTURE)This);
|
||||||
hres = IDsCaptureDriver_QueryInterface(This->driver, riid, ppobj);
|
*ppobj = This;
|
||||||
if (hres != DS_OK)
|
return DS_OK;
|
||||||
WARN("IDsCaptureDriver_QueryInterface failed\n");
|
} else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) {
|
||||||
return hres;
|
IDirectSoundCapture_AddRef((LPDIRECTSOUNDCAPTURE)This);
|
||||||
|
*ppobj = This;
|
||||||
|
return DS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
WARN("unsupported riid: %s\n", debugstr_guid(riid));
|
WARN("unsupported riid: %s\n", debugstr_guid(riid));
|
||||||
return E_FAIL;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI
|
static ULONG WINAPI
|
||||||
|
@ -492,7 +493,6 @@ static ULONG DirectSoundCaptureDevice_Release(
|
||||||
DirectSoundCaptureDevice * device)
|
DirectSoundCaptureDevice * device)
|
||||||
{
|
{
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
|
|
||||||
TRACE("(%p) ref was %lu\n", device, device->ref);
|
TRACE("(%p) ref was %lu\n", device, device->ref);
|
||||||
|
|
||||||
device->ref--;
|
device->ref--;
|
||||||
|
@ -506,7 +506,7 @@ static ULONG DirectSoundCaptureDevice_Release(
|
||||||
if (device->driver) {
|
if (device->driver) {
|
||||||
IDsCaptureDriver_Close(device->driver);
|
IDsCaptureDriver_Close(device->driver);
|
||||||
IDsCaptureDriver_Release(device->driver);
|
IDsCaptureDriver_Release(device->driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, device->pwfx);
|
HeapFree(GetProcessHeap(), 0, device->pwfx);
|
||||||
device->lock.DebugInfo->Spare[1] = 0;
|
device->lock.DebugInfo->Spare[1] = 0;
|
||||||
|
@ -590,6 +590,11 @@ IDirectSoundCaptureImpl_GetCaps(
|
||||||
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
|
||||||
TRACE("(%p,%p)\n",This,lpDSCCaps);
|
TRACE("(%p,%p)\n",This,lpDSCCaps);
|
||||||
|
|
||||||
|
if (This->device == NULL) {
|
||||||
|
WARN("not initialized\n");
|
||||||
|
return DSERR_UNINITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
if (lpDSCCaps== NULL) {
|
if (lpDSCCaps== NULL) {
|
||||||
WARN("invalid parameter: lpDSCCaps== NULL\n");
|
WARN("invalid parameter: lpDSCCaps== NULL\n");
|
||||||
return DSERR_INVALIDPARAM;
|
return DSERR_INVALIDPARAM;
|
||||||
|
@ -601,11 +606,6 @@ IDirectSoundCaptureImpl_GetCaps(
|
||||||
return DSERR_INVALIDPARAM;
|
return DSERR_INVALIDPARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !(This->device) ) {
|
|
||||||
WARN("not initialized\n");
|
|
||||||
return DSERR_UNINITIALIZED;
|
|
||||||
}
|
|
||||||
|
|
||||||
lpDSCCaps->dwFlags = This->device->drvcaps.dwFlags;
|
lpDSCCaps->dwFlags = This->device->drvcaps.dwFlags;
|
||||||
lpDSCCaps->dwFormats = This->device->drvcaps.dwFormats;
|
lpDSCCaps->dwFormats = This->device->drvcaps.dwFormats;
|
||||||
lpDSCCaps->dwChannels = This->device->drvcaps.dwChannels;
|
lpDSCCaps->dwChannels = This->device->drvcaps.dwChannels;
|
||||||
|
@ -677,7 +677,7 @@ IDirectSoundCaptureImpl_Initialize(
|
||||||
WARN("DirectSoundCaptureDevice_Create failed\n");
|
WARN("DirectSoundCaptureDevice_Create failed\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
This->device = device;
|
This->device = device;
|
||||||
device->guid = devGUID;
|
device->guid = devGUID;
|
||||||
|
|
||||||
|
@ -1771,10 +1771,7 @@ DSCCF_CreateInstance(
|
||||||
*ppobj = NULL;
|
*ppobj = NULL;
|
||||||
|
|
||||||
if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) )
|
if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) )
|
||||||
return DSOUND_CaptureCreate((LPDIRECTSOUNDCAPTURE*)ppobj,pOuter);
|
return DSOUND_CaptureCreate8((LPDIRECTSOUNDCAPTURE*)ppobj,pOuter);
|
||||||
|
|
||||||
if ( IsEqualGUID( &IID_IDirectSoundCapture8, riid ) )
|
|
||||||
return DSOUND_CaptureCreate8((LPDIRECTSOUNDCAPTURE8*)ppobj,pOuter);
|
|
||||||
|
|
||||||
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
|
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "dsound.h"
|
#include "dsound.h"
|
||||||
#include "mmreg.h"
|
#include "mmreg.h"
|
||||||
#include "dxerr8.h"
|
#include "dxerr8.h"
|
||||||
|
#include "dsconf.h"
|
||||||
|
|
||||||
#include "dsound_test.h"
|
#include "dsound_test.h"
|
||||||
|
|
||||||
|
@ -101,6 +102,163 @@ static char * format_string(WAVEFORMATEX* wfx)
|
||||||
return str;
|
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 {
|
typedef struct {
|
||||||
char* wave;
|
char* wave;
|
||||||
DWORD wave_len;
|
DWORD wave_len;
|
||||||
|
@ -552,6 +710,7 @@ START_TEST(capture)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IDirectSoundCapture_tests();
|
||||||
capture_tests();
|
capture_tests();
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
|
|
Loading…
Reference in New Issue