dsound: Add COM aggregation to DirectSoundCapture for internal use.

This commit is contained in:
Michael Stefaniuc 2012-08-16 01:49:10 +02:00 committed by Alexandre Julliard
parent ac3cd73ca2
commit 850b294efa
2 changed files with 18 additions and 10 deletions

View File

@ -997,9 +997,10 @@ static HRESULT DirectSoundCaptureDevice_Initialize(
*/ */
typedef struct IDirectSoundCaptureImpl typedef struct IDirectSoundCaptureImpl
{ {
IUnknown IUnknown_iface; /* Separate refcount */ IUnknown IUnknown_inner;
IDirectSoundCapture IDirectSoundCapture_iface; IDirectSoundCapture IDirectSoundCapture_iface;
LONG ref, refdsc, numIfaces; LONG ref, refdsc, numIfaces;
IUnknown *outer_unk; /* internal */
DirectSoundCaptureDevice *device; DirectSoundCaptureDevice *device;
BOOL has_dsc8; BOOL has_dsc8;
} IDirectSoundCaptureImpl; } IDirectSoundCaptureImpl;
@ -1017,7 +1018,7 @@ static void capture_destroy(IDirectSoundCaptureImpl *This)
*/ */
static inline IDirectSoundCaptureImpl *impl_from_IUnknown(IUnknown *iface) static inline IDirectSoundCaptureImpl *impl_from_IUnknown(IUnknown *iface)
{ {
return CONTAINING_RECORD(iface, IDirectSoundCaptureImpl, IUnknown_iface); return CONTAINING_RECORD(iface, IDirectSoundCaptureImpl, IUnknown_inner);
} }
static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
@ -1033,7 +1034,7 @@ static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid,
*ppv = NULL; *ppv = NULL;
if (IsEqualIID(riid, &IID_IUnknown)) if (IsEqualIID(riid, &IID_IUnknown))
*ppv = &This->IUnknown_iface; *ppv = &This->IUnknown_inner;
else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) else if (IsEqualIID(riid, &IID_IDirectSoundCapture))
*ppv = &This->IDirectSoundCapture_iface; *ppv = &This->IDirectSoundCapture_iface;
else { else {
@ -1089,7 +1090,7 @@ static HRESULT WINAPI IDirectSoundCaptureImpl_QueryInterface(IDirectSoundCapture
{ {
IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(iface); IDirectSoundCaptureImpl *This = impl_from_IDirectSoundCapture(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv); TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv);
return IUnknown_QueryInterface(&This->IUnknown_iface, riid, ppv); return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
} }
static ULONG WINAPI IDirectSoundCaptureImpl_AddRef(IDirectSoundCapture *iface) static ULONG WINAPI IDirectSoundCaptureImpl_AddRef(IDirectSoundCapture *iface)
@ -1219,7 +1220,7 @@ static const IDirectSoundCaptureVtbl dscvt =
IDirectSoundCaptureImpl_Initialize IDirectSoundCaptureImpl_Initialize
}; };
static HRESULT IDirectSoundCaptureImpl_Create(REFIID riid, void **ppv, BOOL has_dsc8) HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_dsc8)
{ {
IDirectSoundCaptureImpl *obj; IDirectSoundCaptureImpl *obj;
HRESULT hr; HRESULT hr;
@ -1235,7 +1236,7 @@ static HRESULT IDirectSoundCaptureImpl_Create(REFIID riid, void **ppv, BOOL has_
setup_dsound_options(); setup_dsound_options();
obj->IUnknown_iface.lpVtbl = &unk_vtbl; obj->IUnknown_inner.lpVtbl = &unk_vtbl;
obj->IDirectSoundCapture_iface.lpVtbl = &dscvt; obj->IDirectSoundCapture_iface.lpVtbl = &dscvt;
obj->ref = 1; obj->ref = 1;
obj->refdsc = 0; obj->refdsc = 0;
@ -1243,20 +1244,26 @@ static HRESULT IDirectSoundCaptureImpl_Create(REFIID riid, void **ppv, BOOL has_
obj->device = NULL; obj->device = NULL;
obj->has_dsc8 = has_dsc8; obj->has_dsc8 = has_dsc8;
hr = IUnknown_QueryInterface(&obj->IUnknown_iface, riid, ppv); /* COM aggregation supported only internally */
IUnknown_Release(&obj->IUnknown_iface); if (outer_unk)
obj->outer_unk = outer_unk;
else
obj->outer_unk = &obj->IUnknown_inner;
hr = IUnknown_QueryInterface(&obj->IUnknown_inner, riid, ppv);
IUnknown_Release(&obj->IUnknown_inner);
return hr; return hr;
} }
HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv) HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv)
{ {
return IDirectSoundCaptureImpl_Create(riid, ppv, FALSE); return IDirectSoundCaptureImpl_Create(NULL, riid, ppv, FALSE);
} }
HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv) HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv)
{ {
return IDirectSoundCaptureImpl_Create(riid, ppv, TRUE); return IDirectSoundCaptureImpl_Create(NULL, riid, ppv, TRUE);
} }
/*************************************************************************** /***************************************************************************

View File

@ -301,6 +301,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN; HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv) DECLSPEC_HIDDEN; HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_dsc8) DECLSPEC_HIDDEN;
#define STATE_STOPPED 0 #define STATE_STOPPED 0
#define STATE_STARTING 1 #define STATE_STARTING 1