Do initialization to match windows behavior (with test).

This commit is contained in:
Robert Reif 2004-07-19 20:06:22 +00:00 committed by Alexandre Julliard
parent aaafbc7959
commit 3ce9c5f4b8
4 changed files with 115 additions and 21 deletions

View File

@ -303,6 +303,11 @@ static HRESULT WINAPI IDirectSoundImpl_CreateSoundBuffer(
return DSERR_INVALIDPARAM;
}
if (This->initialized == FALSE) {
WARN("not initialized\n");
return DSERR_UNINITIALIZED;
}
if (dsbd == NULL) {
WARN("invalid parameter: dsbd == NULL\n");
return DSERR_INVALIDPARAM;
@ -379,6 +384,11 @@ static HRESULT WINAPI IDirectSoundImpl_GetCaps(
return DSERR_INVALIDPARAM;
}
if (This->initialized == FALSE) {
WARN("not initialized\n");
return DSERR_UNINITIALIZED;
}
if (lpDSCaps == NULL) {
WARN("invalid parameter: lpDSCaps = NULL\n");
return DSERR_INVALIDPARAM;
@ -436,6 +446,11 @@ static HRESULT WINAPI IDirectSoundImpl_DuplicateSoundBuffer(
return DSERR_INVALIDPARAM;
}
if (This->initialized == FALSE) {
WARN("not initialized\n");
return DSERR_UNINITIALIZED;
}
if (psb == NULL) {
WARN("invalid parameter: psb == NULL\n");
return DSERR_INVALIDPARAM;
@ -577,6 +592,11 @@ static HRESULT WINAPI IDirectSoundImpl_GetSpeakerConfig(
ICOM_THIS(IDirectSoundImpl,iface);
TRACE("(%p, %p)\n",This,lpdwSpeakerConfig);
if (This->initialized == FALSE) {
WARN("not initialized\n");
return DSERR_UNINITIALIZED;
}
if (lpdwSpeakerConfig == NULL) {
WARN("invalid parameter: lpdwSpeakerConfig == NULL\n");
return DSERR_INVALIDPARAM;
@ -594,6 +614,11 @@ static HRESULT WINAPI IDirectSoundImpl_SetSpeakerConfig(
ICOM_THIS(IDirectSoundImpl,iface);
TRACE("(%p,0x%08lx)\n",This,config);
if (This->initialized == FALSE) {
WARN("not initialized\n");
return DSERR_UNINITIALIZED;
}
This->speaker_config = config;
WARN("not fully functional\n");
return DS_OK;
@ -606,6 +631,8 @@ static HRESULT WINAPI IDirectSoundImpl_Initialize(
ICOM_THIS(IDirectSoundImpl,iface);
TRACE("(%p,%s)\n",This,debugstr_guid(lpcGuid));
This->initialized = TRUE;
return DS_OK;
}
@ -616,6 +643,11 @@ static HRESULT WINAPI IDirectSoundImpl_VerifyCertification(
ICOM_THIS(IDirectSoundImpl,iface);
TRACE("(%p, %p)\n",This,pdwCertified);
if (This->initialized == FALSE) {
WARN("not initialized\n");
return DSERR_UNINITIALIZED;
}
if (This->drvcaps.dwFlags & DSCAPS_CERTIFIED)
*pdwCertified = DS_CERTIFIED;
else
@ -718,6 +750,7 @@ HRESULT WINAPI IDirectSoundImpl_Create(
pDS->buffers = NULL;
pDS->primary = NULL;
pDS->speaker_config = DSSPEAKER_STEREO | (DSSPEAKER_GEOMETRY_NARROW << 16);
pDS->initialized = FALSE;
/* 3D listener initial parameters */
pDS->listener = NULL;
@ -1524,22 +1557,7 @@ HRESULT WINAPI IDirectSound8_IDirectSound8_Create(
return DS_OK;
}
/*******************************************************************************
* DirectSoundCreate (DSOUND.1)
*
* Creates and initializes a DirectSound interface.
*
* PARAMS
* lpcGUID [I] Address of the GUID that identifies the sound device.
* ppDS [O] Address of a variable to receive the interface pointer.
* pUnkOuter [I] Must be NULL.
*
* RETURNS
* Success: DS_OK
* Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
* DSERR_NODRIVER, DSERR_OUTOFMEMORY
*/
HRESULT WINAPI DirectSoundCreate(
HRESULT WINAPI DSOUND_Create(
LPCGUID lpcGUID,
LPDIRECTSOUND *ppDS,
IUnknown *pUnkOuter)
@ -1549,6 +1567,11 @@ HRESULT WINAPI DirectSoundCreate(
TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
if (pUnkOuter != NULL) {
WARN("invalid parameter: pUnkOuter != NULL\n");
return DSERR_INVALIDPARAM;
}
if (ppDS == NULL) {
WARN("invalid parameter: ppDS == NULL\n");
return DSERR_INVALIDPARAM;
@ -1609,9 +1632,9 @@ HRESULT WINAPI DirectSoundCreate(
}
/*******************************************************************************
* DirectSoundCreate8 (DSOUND.11)
* DirectSoundCreate (DSOUND.1)
*
* Creates and initializes a DirectSound8 interface.
* Creates and initializes a DirectSound interface.
*
* PARAMS
* lpcGUID [I] Address of the GUID that identifies the sound device.
@ -1623,7 +1646,23 @@ HRESULT WINAPI DirectSoundCreate(
* Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
* DSERR_NODRIVER, DSERR_OUTOFMEMORY
*/
HRESULT WINAPI DirectSoundCreate8(
HRESULT WINAPI DirectSoundCreate(
LPCGUID lpcGUID,
LPDIRECTSOUND *ppDS,
IUnknown *pUnkOuter)
{
HRESULT hr;
TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
hr = DSOUND_Create(lpcGUID, ppDS, pUnkOuter);
if (hr == DS_OK)
IDirectSoundImpl_Initialize((LPDIRECTSOUND8)dsound, lpcGUID);
return hr;
}
HRESULT WINAPI DSOUND_Create8(
LPCGUID lpcGUID,
LPDIRECTSOUND8 *ppDS,
IUnknown *pUnkOuter)
@ -1633,6 +1672,11 @@ HRESULT WINAPI DirectSoundCreate8(
TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
if (pUnkOuter != NULL) {
WARN("invalid parameter: pUnkOuter != NULL\n");
return DSERR_INVALIDPARAM;
}
if (ppDS == NULL) {
WARN("invalid parameter: ppDS == NULL\n");
return DSERR_INVALIDPARAM;
@ -1691,3 +1735,34 @@ HRESULT WINAPI DirectSoundCreate8(
return hr;
}
/*******************************************************************************
* DirectSoundCreate8 (DSOUND.11)
*
* Creates and initializes a DirectSound8 interface.
*
* PARAMS
* lpcGUID [I] Address of the GUID that identifies the sound device.
* ppDS [O] Address of a variable to receive the interface pointer.
* pUnkOuter [I] Must be NULL.
*
* RETURNS
* Success: DS_OK
* Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
* DSERR_NODRIVER, DSERR_OUTOFMEMORY
*/
HRESULT WINAPI DirectSoundCreate8(
LPCGUID lpcGUID,
LPDIRECTSOUND8 *ppDS,
IUnknown *pUnkOuter)
{
HRESULT hr;
TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
hr = DSOUND_Create8(lpcGUID, ppDS, pUnkOuter);
if (hr == DS_OK)
IDirectSoundImpl_Initialize((LPDIRECTSOUND8)dsound, lpcGUID);
return hr;
}

View File

@ -478,10 +478,10 @@ static HRESULT WINAPI DSCF_CreateInstance(
*ppobj = NULL;
if ( IsEqualIID( &IID_IDirectSound, riid ) )
return DirectSoundCreate(0,(LPDIRECTSOUND*)ppobj,pOuter);
return DSOUND_Create(0,(LPDIRECTSOUND*)ppobj,pOuter);
if ( IsEqualIID( &IID_IDirectSound8, riid ) )
return DirectSoundCreate8(0,(LPDIRECTSOUND8*)ppobj,pOuter);
return DSOUND_Create8(0,(LPDIRECTSOUND8*)ppobj,pOuter);
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;

View File

@ -95,6 +95,7 @@ struct IDirectSoundImpl
PrimaryBufferImpl* primary;
DSBUFFERDESC dsbd;
DWORD speaker_config;
BOOL initialized;
/* DirectSound3DListener fields */
IDirectSound3DListenerImpl* listener;
@ -117,6 +118,16 @@ HRESULT WINAPI IDirectSoundImpl_Create(
LPCGUID lpcGUID,
LPDIRECTSOUND8 * ppds);
HRESULT WINAPI DSOUND_Create(
LPCGUID lpcGUID,
LPDIRECTSOUND *ppDS,
IUnknown *pUnkOuter);
HRESULT WINAPI DSOUND_Create8(
LPCGUID lpcGUID,
LPDIRECTSOUND8 *ppDS,
IUnknown *pUnkOuter);
/*****************************************************************************
* IDirectSound COM components
*/

View File

@ -69,6 +69,10 @@ static void dsound_dsound_tests()
if (rc==DS_OK)
IDirectSound8_Release(ds8);
/* try unitialized object */
rc=IDirectSound_GetCaps(dso,0);
ok(rc==DSERR_UNINITIALIZED,"GetCaps should have returned DSERR_UNINITIALIZED, returned: %s\n",DXGetErrorString9(rc));
rc=IDirectSound_Initialize(dso,NULL);
ok(rc==DS_OK,"IDirectSound_Initialize(NULL) failed: %s\n",DXGetErrorString9(rc));
@ -171,6 +175,10 @@ static void dsound_dsound8_tests()
if (rc==DS_OK)
IDirectSound8_Release(ds8);
/* try unitialized object */
rc=IDirectSound8_GetCaps(dso,0);
ok(rc==DSERR_UNINITIALIZED,"GetCaps should have returned DSERR_UNINITIALIZED, returned: %s\n",DXGetErrorString9(rc));
rc=IDirectSound8_Initialize(dso,NULL);
ok(rc==DS_OK,"IDirectSound_Initialize(NULL) failed: %s\n",DXGetErrorString9(rc));