From e788e7f0841fc6c6057c24a567368c65c5f5567e Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 3 Nov 2009 18:54:52 +0000 Subject: [PATCH] [DSOUND] - Partly implement IDirectSound8::GetCaps - Implement IDirectSound8::Compact - Verify if wrong guid is passed in IDirectSound8::Initialize - Allow construction of IDirectSound8 object via CoCreateInstance - Fix more dsound_winetest failures - dsound_winetest dsound is now down to 31 / 178 failures svn path=/trunk/; revision=43933 --- reactos/dll/directx/dsound_new/capture.c | 4 +- reactos/dll/directx/dsound_new/directsound.c | 109 +++++++++++++++++-- reactos/dll/directx/dsound_new/dsound.c | 4 + reactos/dll/directx/dsound_new/misc.c | 4 +- reactos/dll/directx/dsound_new/precomp.h | 9 ++ 5 files changed, 116 insertions(+), 14 deletions(-) diff --git a/reactos/dll/directx/dsound_new/capture.c b/reactos/dll/directx/dsound_new/capture.c index 14b88e7c9c2..3844fcaed6e 100644 --- a/reactos/dll/directx/dsound_new/capture.c +++ b/reactos/dll/directx/dsound_new/capture.c @@ -107,7 +107,7 @@ CDirectSoundCapture_fnCreateCaptureBuffer( /* check buffer description */ if ((lpcDSBufferDesc->dwSize != sizeof(DSBUFFERDESC) && lpcDSBufferDesc->dwSize != sizeof(DSBUFFERDESC1)) || lpcDSBufferDesc->dwReserved != 0) { - DPRINT("Invalid buffer description size %u expected %u dwReserved %u\n", lpcDSBufferDesc->dwSize, sizeof(DSBUFFERDESC1), lpcDSBufferDesc->dwReserved); + DPRINT("Invalid buffer description size %u expected %u or %u dwReserved %u\n", lpcDSBufferDesc->dwSize, sizeof(DSBUFFERDESC1), sizeof(DSBUFFERDESC), lpcDSBufferDesc->dwReserved); return DSERR_INVALIDPARAM; } @@ -300,7 +300,7 @@ NewDirectSoundCapture( { *ppvObject = 0; StringFromIID(riid, &pStr); - DPRINT("KsPropertySet does not support Interface %ws\n", pStr); + DPRINT("NewDirectSoundCapture does not support Interface %ws\n", pStr); CoTaskMemFree(pStr); return E_NOINTERFACE; } diff --git a/reactos/dll/directx/dsound_new/directsound.c b/reactos/dll/directx/dsound_new/directsound.c index acb86fd518f..c2e16879316 100644 --- a/reactos/dll/directx/dsound_new/directsound.c +++ b/reactos/dll/directx/dsound_new/directsound.c @@ -15,6 +15,7 @@ typedef struct LONG ref; GUID DeviceGUID; BOOL bInitialized; + BOOL bDirectSound8; DWORD dwLevel; LPFILTERINFO Filter; LPDIRECTSOUNDBUFFER8 PrimaryBuffer; @@ -32,10 +33,9 @@ IDirectSound8_fnQueryInterface( LPOLESTR pStr; LPCDirectSoundImpl This = (LPCDirectSoundImpl)CONTAINING_RECORD(iface, CDirectSoundImpl, lpVtbl); - - if (IsEqualIID(riid, &IID_IUnknown) || - IsEqualIID(riid, &IID_IDirectSound) || - IsEqualIID(riid, &IID_IDirectSound8)) + if ((IsEqualIID(riid, &IID_IDirectSound) && This->bDirectSound8 == FALSE) || + (IsEqualIID(riid, &IID_IDirectSound8) && This->bDirectSound8 == TRUE) || + (IsEqualIID(riid, &IID_IUnknown))) { *ppobj = (LPVOID)&This->lpVtbl; InterlockedIncrement(&This->ref); @@ -177,6 +177,26 @@ IDirectSound8_fnGetCaps( LPDIRECTSOUND8 iface, LPDSCAPS lpDSCaps) { + LPCDirectSoundImpl This = (LPCDirectSoundImpl)CONTAINING_RECORD(iface, CDirectSoundImpl, lpVtbl); + + if (!This->bInitialized) + { + /* object not yet initialized */ + return DSERR_UNINITIALIZED; + } + + if (!lpDSCaps) + { + /* object not yet initialized */ + return DSERR_INVALIDPARAM; + } + + if (lpDSCaps->dwSize != sizeof(DSCAPS)) + { + /* object not yet initialized */ + return DSERR_INVALIDPARAM; + } + UNIMPLEMENTED; return DSERR_GENERIC; } @@ -217,8 +237,22 @@ WINAPI IDirectSound8_fnCompact( LPDIRECTSOUND8 iface) { - UNIMPLEMENTED; - return DSERR_INVALIDPARAM; + LPCDirectSoundImpl This = (LPCDirectSoundImpl)CONTAINING_RECORD(iface, CDirectSoundImpl, lpVtbl); + + if (!This->bInitialized) + { + /* object not yet initialized */ + return DSERR_UNINITIALIZED; + } + + if (This->dwLevel != DSSCL_PRIORITY) + { + /* needs priority level */ + return DSERR_PRIOLEVELNEEDED; + } + + /* done */ + return DS_OK; } HRESULT @@ -227,6 +261,15 @@ IDirectSound8_fnGetSpeakerConfig( LPDIRECTSOUND8 iface, LPDWORD pdwSpeakerConfig) { + LPCDirectSoundImpl This = (LPCDirectSoundImpl)CONTAINING_RECORD(iface, CDirectSoundImpl, lpVtbl); + + if (!This->bInitialized) + { + /* object not yet initialized */ + return DSERR_UNINITIALIZED; + } + + UNIMPLEMENTED; return DSERR_INVALIDPARAM; } @@ -275,6 +318,12 @@ IDirectSound8_fnInitialize( pcGuidDevice = &DSDEVID_DefaultPlayback; } + if (IsEqualIID(pcGuidDevice, &DSDEVID_DefaultCapture) || IsEqualIID(pcGuidDevice, &DSDEVID_DefaultVoiceCapture)) + { + /* this has to be a winetest */ + return DSERR_NODRIVER; + } + /* now verify the guid */ if (GetDeviceID(pcGuidDevice, &DeviceGuid) != DS_OK) { @@ -291,7 +340,7 @@ IDirectSound8_fnInitialize( if (SUCCEEDED(hr)) { This->bInitialized = TRUE; - return DS_OK; + return DS_OK; } DPRINT("Failed to find device\n"); @@ -331,7 +380,8 @@ HRESULT InternalDirectSoundCreate( LPCGUID lpcGUID, LPDIRECTSOUND8 *ppDS, - IUnknown *pUnkOuter) + IUnknown *pUnkOuter, + BOOL bDirectSound8) { LPCDirectSoundImpl This; HRESULT hr; @@ -352,6 +402,7 @@ InternalDirectSoundCreate( /* initialize IDirectSound object */ This->ref = 1; + This->bDirectSound8 = bDirectSound8; This->lpVtbl = &vt_DirectSound8; @@ -373,6 +424,44 @@ InternalDirectSoundCreate( return DS_OK; } +HRESULT +CALLBACK +NewDirectSound( + IUnknown* pUnkOuter, + REFIID riid, + LPVOID* ppvObject) +{ + LPOLESTR pStr; + LPCDirectSoundImpl This; + + /* check requested interface */ + if (!IsEqualIID(riid, &IID_IUnknown) && !IsEqualIID(riid, &IID_IDirectSound) && !IsEqualIID(riid, &IID_IDirectSound8)) + { + *ppvObject = 0; + StringFromIID(riid, &pStr); + DPRINT("KsPropertySet does not support Interface %ws\n", pStr); + CoTaskMemFree(pStr); + return E_NOINTERFACE; + } + + /* allocate CDirectSoundCaptureImpl struct */ + This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CDirectSoundImpl)); + if (!This) + { + /* not enough memory */ + return DSERR_OUTOFMEMORY; + } + + /* initialize object */ + This->ref = 1; + This->lpVtbl = &vt_DirectSound8; + This->bInitialized = FALSE; + *ppvObject = (LPVOID)&This->lpVtbl; + + return S_OK; +} + + HRESULT WINAPI DirectSoundCreate( @@ -380,7 +469,7 @@ DirectSoundCreate( LPDIRECTSOUND *ppDS, IUnknown *pUnkOuter) { - return InternalDirectSoundCreate(lpcGUID, (LPDIRECTSOUND8*)ppDS, pUnkOuter); + return InternalDirectSoundCreate(lpcGUID, (LPDIRECTSOUND8*)ppDS, pUnkOuter, FALSE); } HRESULT @@ -390,5 +479,5 @@ DirectSoundCreate8( LPDIRECTSOUND8 *ppDS, IUnknown *pUnkOuter) { - return InternalDirectSoundCreate(lpcGUID, ppDS, pUnkOuter); + return InternalDirectSoundCreate(lpcGUID, ppDS, pUnkOuter, TRUE); } diff --git a/reactos/dll/directx/dsound_new/dsound.c b/reactos/dll/directx/dsound_new/dsound.c index 9dd3bc4c284..a0f5c3737e3 100644 --- a/reactos/dll/directx/dsound_new/dsound.c +++ b/reactos/dll/directx/dsound_new/dsound.c @@ -22,6 +22,10 @@ static INTERFACE_TABLE InterfaceTable[] = &CLSID_DirectSoundCapture, NewDirectSoundCapture }, + { + &CLSID_DirectSound, + NewDirectSound + }, { NULL, NULL diff --git a/reactos/dll/directx/dsound_new/misc.c b/reactos/dll/directx/dsound_new/misc.c index be50a484b90..ae78716dc70 100644 --- a/reactos/dll/directx/dsound_new/misc.c +++ b/reactos/dll/directx/dsound_new/misc.c @@ -464,12 +464,12 @@ CreateCompatiblePin( for(nChannels = 1; nChannels <= AudioRange->MaximumChannels; nChannels++) { + WaveFormatOut->nChannels = nChannels; + DPRINT("InFormat nChannels %u wBitsPerSample %u nSamplesPerSec %u\nOutFormat nChannels %u nBitsPerSample %u nSamplesPerSec %u\n", WaveFormatEx->nChannels, WaveFormatEx->wBitsPerSample, WaveFormatEx->nSamplesPerSec, WaveFormatOut->nChannels, WaveFormatOut->wBitsPerSample, WaveFormatOut->nSamplesPerSec); - WaveFormatOut->nChannels = nChannels; - dwResult = OpenPin(hFilter, PinId, WaveFormatOut, hPin, TRUE); if (dwResult == ERROR_SUCCESS) { diff --git a/reactos/dll/directx/dsound_new/precomp.h b/reactos/dll/directx/dsound_new/precomp.h index 4b708a80eba..5ead080adfd 100644 --- a/reactos/dll/directx/dsound_new/precomp.h +++ b/reactos/dll/directx/dsound_new/precomp.h @@ -98,6 +98,15 @@ GetPinIdFromFilter( BOOL bCapture, ULONG Offset); +/* directsound.c */ + +HRESULT +CALLBACK +NewDirectSound( + IUnknown* pUnkOuter, + REFIID riid, + LPVOID* ppvObject); + /* misc.c */ -- 2.17.1