dsound: COM cleanup for the IDirectSoundFullDuplex iface.

This commit is contained in:
Michael Stefaniuc 2012-08-16 01:31:52 +02:00 committed by Alexandre Julliard
parent f6f8123c6b
commit 8588260eef
1 changed files with 29 additions and 30 deletions

View File

@ -42,8 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
*/ */
typedef struct IDirectSoundFullDuplexImpl typedef struct IDirectSoundFullDuplexImpl
{ {
/* IUnknown fields */ IDirectSoundFullDuplex IDirectSoundFullDuplex_iface;
const IDirectSoundFullDuplexVtbl *lpVtbl;
LONG ref; LONG ref;
/* IDirectSoundFullDuplexImpl fields */ /* IDirectSoundFullDuplexImpl fields */
@ -159,7 +158,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSound8_QueryInterface(
{ {
IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface; IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface;
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj); return IDirectSoundFullDuplex_QueryInterface(&This->pdsfd->IDirectSoundFullDuplex_iface, riid, ppobj);
} }
static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_AddRef( static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_AddRef(
@ -334,7 +333,7 @@ static HRESULT WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_QueryInterface(
{ {
IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface; IDirectSoundFullDuplex_IDirectSoundCapture *This = (IDirectSoundFullDuplex_IDirectSoundCapture *)iface;
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj); TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
return IDirectSoundFullDuplex_QueryInterface((LPDIRECTSOUNDFULLDUPLEX)This->pdsfd, riid, ppobj); return IDirectSoundFullDuplex_QueryInterface(&This->pdsfd->IDirectSoundFullDuplex_iface, riid, ppobj);
} }
static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_AddRef( static ULONG WINAPI IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(
@ -439,48 +438,49 @@ static HRESULT IDirectSoundFullDuplex_IDirectSoundCapture_Create(
} }
/*************************************************************************** /***************************************************************************
* IDirectSoundFullDuplexImpl * IDirectSoundFullDuplex implementation
*/ */
static ULONG WINAPI static inline IDirectSoundFullDuplexImpl *impl_from_IDirectSoundFullDuplex(IDirectSoundFullDuplex *iface)
IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface )
{ {
IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; return CONTAINING_RECORD(iface, IDirectSoundFullDuplexImpl, IDirectSoundFullDuplex_iface);
}
static ULONG WINAPI IDirectSoundFullDuplexImpl_AddRef(IDirectSoundFullDuplex *iface)
{
IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
ULONG ref = InterlockedIncrement(&(This->ref)); ULONG ref = InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %d\n", This, ref - 1); TRACE("(%p) ref was %d\n", This, ref - 1);
return ref; return ref;
} }
static HRESULT WINAPI static HRESULT WINAPI IDirectSoundFullDuplexImpl_QueryInterface(IDirectSoundFullDuplex *iface,
IDirectSoundFullDuplexImpl_QueryInterface( REFIID riid, void **ppv)
LPDIRECTSOUNDFULLDUPLEX iface,
REFIID riid,
LPVOID* ppobj )
{ {
IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj ); TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv);
if (ppobj == NULL) { if (ppv == NULL) {
WARN("invalid parameter\n"); WARN("invalid parameter\n");
return E_INVALIDARG; return E_INVALIDARG;
} }
*ppobj = NULL; *ppv = NULL;
if (IsEqualIID(riid, &IID_IUnknown)) { if (IsEqualIID(riid, &IID_IUnknown)) {
if (!This->pUnknown) { if (!This->pUnknown) {
IDirectSoundFullDuplex_IUnknown_Create(iface, &This->pUnknown); IDirectSoundFullDuplex_IUnknown_Create(iface, &This->pUnknown);
if (!This->pUnknown) { if (!This->pUnknown) {
WARN("IDirectSoundFullDuplex_IUnknown_Create() failed\n"); WARN("IDirectSoundFullDuplex_IUnknown_Create() failed\n");
*ppobj = NULL; *ppv = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
} }
IDirectSoundFullDuplex_IUnknown_AddRef(This->pUnknown); IDirectSoundFullDuplex_IUnknown_AddRef(This->pUnknown);
*ppobj = This->pUnknown; *ppv = This->pUnknown;
return S_OK; return S_OK;
} else if (IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) { } else if (IsEqualIID(riid, &IID_IDirectSoundFullDuplex)) {
IDirectSoundFullDuplexImpl_AddRef(iface); IDirectSoundFullDuplexImpl_AddRef(iface);
*ppobj = This; *ppv = &This->IDirectSoundFullDuplex_iface;
return S_OK; return S_OK;
} else if (IsEqualIID(riid, &IID_IDirectSound) } else if (IsEqualIID(riid, &IID_IDirectSound)
|| IsEqualIID(riid, &IID_IDirectSound8)) { || IsEqualIID(riid, &IID_IDirectSound8)) {
@ -488,34 +488,33 @@ IDirectSoundFullDuplexImpl_QueryInterface(
IDirectSoundFullDuplex_IDirectSound8_Create(iface, &This->pDS8); IDirectSoundFullDuplex_IDirectSound8_Create(iface, &This->pDS8);
if (!This->pDS8) { if (!This->pDS8) {
WARN("IDirectSoundFullDuplex_IDirectSound8_Create() failed\n"); WARN("IDirectSoundFullDuplex_IDirectSound8_Create() failed\n");
*ppobj = NULL; *ppv = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
} }
IDirectSoundFullDuplex_IDirectSound8_AddRef(This->pDS8); IDirectSoundFullDuplex_IDirectSound8_AddRef(This->pDS8);
*ppobj = This->pDS8; *ppv = This->pDS8;
return S_OK; return S_OK;
} else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) { } else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) {
if (!This->pDSC) { if (!This->pDSC) {
IDirectSoundFullDuplex_IDirectSoundCapture_Create(iface, &This->pDSC); IDirectSoundFullDuplex_IDirectSoundCapture_Create(iface, &This->pDSC);
if (!This->pDSC) { if (!This->pDSC) {
WARN("IDirectSoundFullDuplex_IDirectSoundCapture_Create() failed\n"); WARN("IDirectSoundFullDuplex_IDirectSoundCapture_Create() failed\n");
*ppobj = NULL; *ppv = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
} }
IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(This->pDSC); IDirectSoundFullDuplex_IDirectSoundCapture_AddRef(This->pDSC);
*ppobj = This->pDSC; *ppv = This->pDSC;
return S_OK; return S_OK;
} }
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI static ULONG WINAPI IDirectSoundFullDuplexImpl_Release(IDirectSoundFullDuplex *iface)
IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
{ {
IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface; IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
ULONG ref = InterlockedDecrement(&(This->ref)); ULONG ref = InterlockedDecrement(&(This->ref));
TRACE("(%p) ref was %d\n", This, ref - 1); TRACE("(%p) ref was %d\n", This, ref - 1);
@ -535,8 +534,8 @@ static HRESULT WINAPI IDirectSoundFullDuplexImpl_Initialize(IDirectSoundFullDupl
const DSBUFFERDESC *bufdesc, HWND hwnd, DWORD level, IDirectSoundCaptureBuffer8 **dscb8, const DSBUFFERDESC *bufdesc, HWND hwnd, DWORD level, IDirectSoundCaptureBuffer8 **dscb8,
IDirectSoundBuffer8 **dsb8) IDirectSoundBuffer8 **dsb8)
{ {
IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
HRESULT hr; HRESULT hr;
IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This, debugstr_guid(capture_dev), TRACE("(%p,%s,%s,%p,%p,%p,%x,%p,%p)\n", This, debugstr_guid(capture_dev),
debugstr_guid(render_dev), cbufdesc, bufdesc, hwnd, level, dscb8, dsb8); debugstr_guid(render_dev), cbufdesc, bufdesc, hwnd, level, dscb8, dsb8);
@ -606,7 +605,7 @@ error:
return hr; return hr;
} }
static const IDirectSoundFullDuplexVtbl dsfdvt = static const IDirectSoundFullDuplexVtbl dsfd_vtbl =
{ {
/* IUnknown methods */ /* IUnknown methods */
IDirectSoundFullDuplexImpl_QueryInterface, IDirectSoundFullDuplexImpl_QueryInterface,
@ -633,7 +632,7 @@ HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv)
setup_dsound_options(); setup_dsound_options();
obj->lpVtbl = &dsfdvt; obj->IDirectSoundFullDuplex_iface.lpVtbl = &dsfd_vtbl;
obj->ref = 1; obj->ref = 1;
hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv); hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv);