From a238f5fb5c21a0a6563e6f3dae20002018fe0126 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 2 Aug 2011 00:37:00 -0700 Subject: [PATCH] Add an IDirectSound interface --- dsound8.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- dsound_private.h | 1 + primary.c | 2 +- 3 files changed, 93 insertions(+), 6 deletions(-) diff --git a/dsound8.c b/dsound8.c index 7cdb8ba..cca689e 100644 --- a/dsound8.c +++ b/dsound8.c @@ -60,12 +60,18 @@ static DS8Impl **devicelist; static UINT devicelistsize; static const IDirectSound8Vtbl DS8_Vtbl; +static const IDirectSoundVtbl DS_Vtbl; static inline DS8Impl *impl_from_IDirectSound8(IDirectSound8 *iface) { return CONTAINING_RECORD(iface, DS8Impl, IDirectSound8_iface); } +static inline DS8Impl *impl_from_IDirectSound(IDirectSound *iface) +{ + return CONTAINING_RECORD(iface, DS8Impl, IDirectSound_iface); +} + HRESULT DSOUND_Create(REFIID riid, void **ds) { HRESULT hr; @@ -110,6 +116,7 @@ HRESULT DSOUND_Create8(REFIID riid, LPVOID *ds) if(!This) return E_OUTOFMEMORY; This->IDirectSound8_iface.lpVtbl = (IDirectSound8Vtbl*)&DS8_Vtbl; + This->IDirectSound_iface.lpVtbl = (IDirectSoundVtbl*)&DS_Vtbl; This->is_8 = TRUE; This->speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_5POINT1, DSSPEAKER_GEOMETRY_WIDE); @@ -323,7 +330,7 @@ static HRESULT WINAPI DS8_CreateSoundBuffer(IDirectSound8 *iface, LPCDSBUFFERDES hr = S_OK; if(IDirectSoundBuffer_AddRef(prim) == 1) { - hr = IDirectSoundBuffer_Initialize(prim, (IDirectSound*)&This->IDirectSound8_iface, desc); + hr = IDirectSoundBuffer_Initialize(prim, &This->IDirectSound_iface, desc); if(FAILED(hr)) { IDirectSoundBuffer_Release(prim); @@ -339,7 +346,7 @@ static HRESULT WINAPI DS8_CreateSoundBuffer(IDirectSound8 *iface, LPCDSBUFFERDES hr = DS8Buffer_Create(&dsb, This->primary, NULL); if(SUCCEEDED(hr)) { - hr = IDirectSoundBuffer8_Initialize(&dsb->IDirectSoundBuffer8_iface, (IDirectSound*)&This->IDirectSound8_iface, desc); + hr = IDirectSoundBuffer8_Initialize(&dsb->IDirectSoundBuffer8_iface, &This->IDirectSound_iface, desc); if(FAILED(hr)) IDirectSoundBuffer8_Release(&dsb->IDirectSoundBuffer8_iface); else @@ -566,7 +573,7 @@ static HRESULT WINAPI DS8_SetCooperativeLevel(IDirectSound8 *iface, HWND hwnd, D if(SUCCEEDED(hr)) { This->primary->write_emu = &emu->IDirectSoundBuffer8_iface; - hr = IDirectSoundBuffer8_Initialize(This->primary->write_emu, (IDirectSound*)&This->IDirectSound8_iface, &desc); + hr = IDirectSoundBuffer8_Initialize(This->primary->write_emu, &This->IDirectSound_iface, &desc); if(FAILED(hr)) { IDirectSoundBuffer8_Release(This->primary->write_emu); @@ -798,8 +805,7 @@ static HRESULT WINAPI DS8_VerifyCertification(IDirectSound8 *iface, DWORD *certi return DS_OK; } -static const IDirectSound8Vtbl DS8_Vtbl = -{ +static const IDirectSound8Vtbl DS8_Vtbl = { DS8_QueryInterface, DS8_AddRef, DS8_Release, @@ -813,3 +819,83 @@ static const IDirectSound8Vtbl DS8_Vtbl = DS8_Initialize, DS8_VerifyCertification }; + + +static HRESULT WINAPI DS_QueryInterface(IDirectSound *iface, REFIID riid, LPVOID *ppv) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_QueryInterface(&This->IDirectSound8_iface, riid, ppv); +} + +static ULONG WINAPI DS_AddRef(IDirectSound *iface) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_AddRef(&This->IDirectSound8_iface); +} + +static ULONG WINAPI DS_Release(IDirectSound *iface) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_Release(&This->IDirectSound8_iface); +} + +static HRESULT WINAPI DS_CreateSoundBuffer(IDirectSound *iface, LPCDSBUFFERDESC desc, LPLPDIRECTSOUNDBUFFER buf, IUnknown *pUnkOuter) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_CreateSoundBuffer(&This->IDirectSound8_iface, desc, buf, pUnkOuter); +} + +static HRESULT WINAPI DS_GetCaps(IDirectSound *iface, LPDSCAPS caps) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_GetCaps(&This->IDirectSound8_iface, caps); +} +static HRESULT WINAPI DS_DuplicateSoundBuffer(IDirectSound *iface, IDirectSoundBuffer *in, IDirectSoundBuffer **out) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_DuplicateSoundBuffer(&This->IDirectSound8_iface, in, out); +} + +static HRESULT WINAPI DS_SetCooperativeLevel(IDirectSound *iface, HWND hwnd, DWORD level) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_SetCooperativeLevel(&This->IDirectSound8_iface, hwnd, level); +} + +static HRESULT WINAPI DS_Compact(IDirectSound *iface) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_Compact(&This->IDirectSound8_iface); +} + +static HRESULT WINAPI DS_GetSpeakerConfig(IDirectSound *iface, DWORD *config) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_GetSpeakerConfig(&This->IDirectSound8_iface, config); +} + +static HRESULT WINAPI DS_SetSpeakerConfig(IDirectSound *iface, DWORD config) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_SetSpeakerConfig(&This->IDirectSound8_iface, config); +} + +static HRESULT WINAPI DS_Initialize(IDirectSound *iface, const GUID *devguid) +{ + DS8Impl *This = impl_from_IDirectSound(iface); + return DS8_Initialize(&This->IDirectSound8_iface, devguid); +} + +static const IDirectSoundVtbl DS_Vtbl = { + DS_QueryInterface, + DS_AddRef, + DS_Release, + DS_CreateSoundBuffer, + DS_GetCaps, + DS_DuplicateSoundBuffer, + DS_SetCooperativeLevel, + DS_Compact, + DS_GetSpeakerConfig, + DS_SetSpeakerConfig, + DS_Initialize +}; diff --git a/dsound_private.h b/dsound_private.h index 9aca216..9f6ba81 100644 --- a/dsound_private.h +++ b/dsound_private.h @@ -308,6 +308,7 @@ typedef struct DS8Buffer DS8Buffer; typedef struct DS8Impl { IDirectSound8 IDirectSound8_iface; + IDirectSound IDirectSound_iface; LONG ref; BOOL is_8; diff --git a/primary.c b/primary.c index 1f5087c..ffbbf21 100644 --- a/primary.c +++ b/primary.c @@ -906,7 +906,7 @@ static HRESULT WINAPI DS8Primary_SetFormat(IDirectSoundBuffer *iface, const WAVE if(FAILED(hr)) goto out; - hr = IDirectSoundBuffer8_Initialize(&buf->IDirectSoundBuffer8_iface, (IDirectSound*)&This->parent->IDirectSound8_iface, &desc); + hr = IDirectSoundBuffer8_Initialize(&buf->IDirectSoundBuffer8_iface, &This->parent->IDirectSound_iface, &desc); if(FAILED(hr)) DS8Buffer_Destroy(buf); else -- 2.11.4.GIT