dsound: COM cleanup for the IDirectSoundCapture iface.

This commit is contained in:
Michael Stefaniuc 2011-10-07 13:28:54 +02:00 committed by Alexandre Julliard
parent a948e5e474
commit f0a3a09d0e
1 changed files with 40 additions and 50 deletions

View File

@ -1065,24 +1065,23 @@ static HRESULT DirectSoundCaptureDevice_Initialize(
*/ */
struct IDirectSoundCaptureImpl struct IDirectSoundCaptureImpl
{ {
/* IUnknown fields */ IDirectSoundCapture IDirectSoundCapture_iface;
const IDirectSoundCaptureVtbl *lpVtbl; LONG ref;
LONG ref; DirectSoundCaptureDevice *device;
DirectSoundCaptureDevice *device;
}; };
static inline struct IDirectSoundCaptureImpl *impl_from_IDirectSoundCapture(IDirectSoundCapture *iface)
{
return CONTAINING_RECORD(iface, struct IDirectSoundCaptureImpl, IDirectSoundCapture_iface);
}
/*************************************************************************** /***************************************************************************
* IDirectSoundCaptureImpl * IDirectSoundCaptureImpl
*/ */
static HRESULT WINAPI static HRESULT WINAPI IDirectSoundCaptureImpl_QueryInterface(IDirectSoundCapture *iface,
IDirectSoundCaptureImpl_QueryInterface( REFIID riid, void **ppobj)
LPDIRECTSOUNDCAPTURE iface,
REFIID riid,
LPVOID* ppobj )
{ {
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; TRACE( "(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj );
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
if (ppobj == NULL) { if (ppobj == NULL) {
WARN("invalid parameter\n"); WARN("invalid parameter\n");
@ -1091,34 +1090,30 @@ IDirectSoundCaptureImpl_QueryInterface(
*ppobj = NULL; *ppobj = NULL;
if (IsEqualIID(riid, &IID_IUnknown)) { if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectSoundCapture)) {
IDirectSoundCapture_AddRef((LPDIRECTSOUNDCAPTURE)This); IDirectSoundCapture_AddRef(iface);
*ppobj = This; *ppobj = iface;
return DS_OK; return S_OK;
} else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) {
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_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI static ULONG WINAPI IDirectSoundCaptureImpl_AddRef(IDirectSoundCapture *iface)
IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface )
{ {
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(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 ULONG WINAPI static ULONG WINAPI IDirectSoundCaptureImpl_Release(IDirectSoundCapture *iface)
IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
{ {
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(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);
if (!ref) { if (!ref) {
@ -1131,14 +1126,12 @@ IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
return ref; return ref;
} }
static HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer( static HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(IDirectSoundCapture *iface,
LPDIRECTSOUNDCAPTURE iface, LPCDSCBUFFERDESC lpcDSCBufferDesc, IDirectSoundCaptureBuffer **lplpDSCaptureBuffer,
LPCDSCBUFFERDESC lpcDSCBufferDesc, IUnknown *pUnk)
LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
LPUNKNOWN pUnk )
{ {
IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(iface);
HRESULT hr; HRESULT hr;
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
TRACE( "(%p,%p,%p,%p)\n",iface,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk); TRACE( "(%p,%p,%p,%p)\n",iface,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk);
@ -1172,11 +1165,11 @@ static HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
return hr; return hr;
} }
static HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps( static HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(IDirectSoundCapture *iface,
LPDIRECTSOUNDCAPTURE iface, LPDSCCAPS lpDSCCaps)
LPDSCCAPS lpDSCCaps )
{ {
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(iface);
TRACE("(%p,%p)\n",This,lpDSCCaps); TRACE("(%p,%p)\n",This,lpDSCCaps);
if (This->device == NULL) { if (This->device == NULL) {
@ -1204,11 +1197,11 @@ static HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
return DS_OK; return DS_OK;
} }
static HRESULT WINAPI IDirectSoundCaptureImpl_Initialize( static HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(IDirectSoundCapture *iface,
LPDIRECTSOUNDCAPTURE iface, LPCGUID lpcGUID)
LPCGUID lpcGUID )
{ {
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(iface);
TRACE("(%p,%s)\n", This, debugstr_guid(lpcGUID)); TRACE("(%p,%s)\n", This, debugstr_guid(lpcGUID));
if (This->device != NULL) { if (This->device != NULL) {
@ -1245,7 +1238,7 @@ static HRESULT IDirectSoundCaptureImpl_Create(
return DSERR_OUTOFMEMORY; return DSERR_OUTOFMEMORY;
} }
pDSC->lpVtbl = &dscvt; pDSC->IDirectSoundCapture_iface.lpVtbl = &dscvt;
pDSC->ref = 0; pDSC->ref = 0;
pDSC->device = NULL; pDSC->device = NULL;
@ -1254,11 +1247,9 @@ static HRESULT IDirectSoundCaptureImpl_Create(
return DS_OK; return DS_OK;
} }
HRESULT DSOUND_CaptureCreate( HRESULT DSOUND_CaptureCreate(REFIID riid, IDirectSoundCapture **ppDSC)
REFIID riid,
LPDIRECTSOUNDCAPTURE *ppDSC)
{ {
LPDIRECTSOUNDCAPTURE pDSC; IDirectSoundCapture *pDSC;
HRESULT hr; HRESULT hr;
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC); TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC);
@ -1334,13 +1325,12 @@ HRESULT DSOUND_CaptureCreate8(
* *
* DSERR_ALLOCATED is returned for sound devices that do not support full duplex. * DSERR_ALLOCATED is returned for sound devices that do not support full duplex.
*/ */
HRESULT WINAPI DirectSoundCaptureCreate( HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID lpcGUID, IDirectSoundCapture **ppDSC,
LPCGUID lpcGUID, IUnknown *pUnkOuter)
LPDIRECTSOUNDCAPTURE *ppDSC,
LPUNKNOWN pUnkOuter)
{ {
HRESULT hr; HRESULT hr;
LPDIRECTSOUNDCAPTURE pDSC; IDirectSoundCapture *pDSC;
TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), ppDSC, pUnkOuter); TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), ppDSC, pUnkOuter);
if (ppDSC == NULL) { if (ppDSC == NULL) {