Michael Stefaniuc : dsound: Add COM aggregation to DirectSound for internal use.
Alexandre Julliard
julliard at winehq.org
Thu Aug 16 15:26:11 CDT 2012
Module: wine
Branch: master
Commit: 9cb53818e85513cd73f621d65fa581abab981a2f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9cb53818e85513cd73f621d65fa581abab981a2f
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Thu Aug 16 01:45:29 2012 +0200
dsound: Add COM aggregation to DirectSound for internal use.
---
dlls/dsound/dsound.c | 27 +++++++++++++++++----------
dlls/dsound/dsound_private.h | 1 +
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index ad41f59..3847a18 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -42,8 +42,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
typedef struct IDirectSoundImpl {
- IUnknown IUnknown_iface; /* Separate refcount, not for COM aggregation */
+ IUnknown IUnknown_inner;
IDirectSound8 IDirectSound8_iface;
+ IUnknown *outer_unk; /* internal */
LONG ref, refds, numIfaces;
DirectSoundDevice *device;
BOOL has_ds8;
@@ -129,7 +130,7 @@ static void directsound_destroy(IDirectSoundImpl *This)
*/
static inline IDirectSoundImpl *impl_from_IUnknown(IUnknown *iface)
{
- return CONTAINING_RECORD(iface, IDirectSoundImpl, IUnknown_iface);
+ return CONTAINING_RECORD(iface, IDirectSoundImpl, IUnknown_inner);
}
static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
@@ -145,7 +146,7 @@ static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid,
*ppv = NULL;
if (IsEqualIID(riid, &IID_IUnknown))
- *ppv = &This->IUnknown_iface;
+ *ppv = &This->IUnknown_inner;
else if (IsEqualIID(riid, &IID_IDirectSound) ||
(IsEqualIID(riid, &IID_IDirectSound8) && This->has_ds8))
*ppv = &This->IDirectSound8_iface;
@@ -204,7 +205,7 @@ static HRESULT WINAPI IDirectSound8Impl_QueryInterface(IDirectSound8 *iface, REF
{
IDirectSoundImpl *This = impl_from_IDirectSound8(iface);
TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv);
- return IUnknown_QueryInterface(&This->IUnknown_iface, riid, ppv);
+ return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
}
static ULONG WINAPI IDirectSound8Impl_AddRef(IDirectSound8 *iface)
@@ -317,7 +318,7 @@ static const IDirectSound8Vtbl ds8_vtbl =
IDirectSound8Impl_VerifyCertification
};
-static HRESULT IDirectSoundImpl_Create(REFIID riid, void **ppv, BOOL has_ds8)
+HRESULT IDirectSoundImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_ds8)
{
IDirectSoundImpl *obj;
HRESULT hr;
@@ -333,7 +334,7 @@ static HRESULT IDirectSoundImpl_Create(REFIID riid, void **ppv, BOOL has_ds8)
setup_dsound_options();
- obj->IUnknown_iface.lpVtbl = &unk_vtbl;
+ obj->IUnknown_inner.lpVtbl = &unk_vtbl;
obj->IDirectSound8_iface.lpVtbl = &ds8_vtbl;
obj->ref = 1;
obj->refds = 0;
@@ -341,20 +342,26 @@ static HRESULT IDirectSoundImpl_Create(REFIID riid, void **ppv, BOOL has_ds8)
obj->device = NULL;
obj->has_ds8 = has_ds8;
- hr = IUnknown_QueryInterface(&obj->IUnknown_iface, riid, ppv);
- IUnknown_Release(&obj->IUnknown_iface);
+ /* COM aggregation supported only internally */
+ 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;
}
HRESULT DSOUND_Create(REFIID riid, void **ppv)
{
- return IDirectSoundImpl_Create(riid, ppv, FALSE);
+ return IDirectSoundImpl_Create(NULL, riid, ppv, FALSE);
}
HRESULT DSOUND_Create8(REFIID riid, void **ppv)
{
- return IDirectSoundImpl_Create(riid, ppv, TRUE);
+ return IDirectSoundImpl_Create(NULL, riid, ppv, TRUE);
}
/*******************************************************************************
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 1855319..d9139be 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -263,6 +263,7 @@ HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DEC
HRESULT DSOUND_Create(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT DSOUND_Create8(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
+HRESULT IDirectSoundImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_ds8) DECLSPEC_HIDDEN;
/* primary.c */
More information about the wine-cvs
mailing list