Michael Stefaniuc : dmcompos: Remove the extraneous IUnknown from DirectMusicChordMap.
Alexandre Julliard
julliard at winehq.org
Tue Mar 11 14:45:40 CDT 2014
Module: wine
Branch: master
Commit: 90f1e180e1ab5cd83fad854de8af4d2260245992
URL: http://source.winehq.org/git/wine.git/?a=commit;h=90f1e180e1ab5cd83fad854de8af4d2260245992
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Mon Mar 10 23:55:42 2014 +0100
dmcompos: Remove the extraneous IUnknown from DirectMusicChordMap.
Also lock/unlock the module only on creation/destruction of the object.
---
dlls/dmcompos/chordmap.c | 125 +++++++++++++++-----------------------
dlls/dmcompos/dmcompos_private.h | 2 -
2 files changed, 49 insertions(+), 78 deletions(-)
diff --git a/dlls/dmcompos/chordmap.c b/dlls/dmcompos/chordmap.c
index 2d22f37..9d2d8a9 100644
--- a/dlls/dmcompos/chordmap.c
+++ b/dlls/dmcompos/chordmap.c
@@ -22,71 +22,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
-static ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface);
-static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
-static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
-
/*****************************************************************************
* IDirectMusicChordMapImpl implementation
*/
-/* IDirectMusicChordMapImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicChordMapImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
- ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface);
- TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
- if (IsEqualIID (riid, &IID_IUnknown)) {
- *ppobj = &This->UnknownVtbl;
- IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicChordMap)) {
- *ppobj = &This->IDirectMusicChordMap_iface;
- IDirectMusicChordMap_AddRef(&This->IDirectMusicChordMap_iface);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
- *ppobj = &This->ObjectVtbl;
- IDirectMusicChordMapImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
- return S_OK;
- } else if (IsEqualIID (riid, &IID_IPersistStream)) {
- *ppobj = &This->PersistStreamVtbl;
- IDirectMusicChordMapImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
- return S_OK;
- }
-
- WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface);
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("(%p): AddRef from %d\n", This, ref - 1);
-
- DMCOMPOS_LockModule();
-
- return ref;
-}
-
-static ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_Release (LPUNKNOWN iface) {
- ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface);
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("(%p): ReleaseRef to %d\n", This, ref);
-
- if (ref == 0) {
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- DMCOMPOS_UnlockModule();
-
- return ref;
-}
-
-static const IUnknownVtbl DirectMusicChordMap_Unknown_Vtbl = {
- IDirectMusicChordMapImpl_IUnknown_QueryInterface,
- IDirectMusicChordMapImpl_IUnknown_AddRef,
- IDirectMusicChordMapImpl_IUnknown_Release
-};
/* IDirectMusicChordMapImpl IDirectMusicChordMap part: */
static inline IDirectMusicChordMapImpl *impl_from_IDirectMusicChordMap(IDirectMusicChordMap *iface)
@@ -95,22 +33,53 @@ static inline IDirectMusicChordMapImpl *impl_from_IDirectMusicChordMap(IDirectMu
}
static HRESULT WINAPI IDirectMusicChordMapImpl_QueryInterface(IDirectMusicChordMap *iface,
- REFIID riid, void **ppobj)
+ REFIID riid, void **ret_iface)
{
IDirectMusicChordMapImpl *This = impl_from_IDirectMusicChordMap(iface);
- return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
+
+ TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
+
+ *ret_iface = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicChordMap))
+ *ret_iface = iface;
+ else if (IsEqualIID(riid, &IID_IDirectMusicObject))
+ *ret_iface = &This->ObjectVtbl;
+ else if (IsEqualIID(riid, &IID_IPersistStream))
+ *ret_iface = &This->PersistStreamVtbl;
+ else {
+ WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
+ return E_NOINTERFACE;
+ }
+
+ IUnknown_AddRef((IUnknown*)*ret_iface);
+ return S_OK;
}
static ULONG WINAPI IDirectMusicChordMapImpl_AddRef(IDirectMusicChordMap *iface)
{
IDirectMusicChordMapImpl *This = impl_from_IDirectMusicChordMap(iface);
- return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+ LONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) ref=%d\n", This, ref);
+
+ return ref;
}
static ULONG WINAPI IDirectMusicChordMapImpl_Release(IDirectMusicChordMap *iface)
{
IDirectMusicChordMapImpl *This = impl_from_IDirectMusicChordMap(iface);
- return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+ LONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) ref=%d\n", This, ref);
+
+ if (!ref) {
+ HeapFree(GetProcessHeap(), 0, This->pDesc);
+ HeapFree(GetProcessHeap(), 0, This);
+ DMCOMPOS_UnlockModule();
+ }
+
+ return ref;
}
static HRESULT WINAPI IDirectMusicChordMapImpl_GetScale(IDirectMusicChordMap *iface,
@@ -131,17 +100,17 @@ static const IDirectMusicChordMapVtbl dmchordmap_vtbl = {
/* IDirectMusicChordMapImpl IDirectMusicObject part: */
static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
- return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
+ return IDirectMusicChordMap_QueryInterface(&This->IDirectMusicChordMap_iface, riid, ppobj);
}
static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
- return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+ return IDirectMusicChordMap_AddRef(&This->IDirectMusicChordMap_iface);
}
static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
- return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+ return IDirectMusicChordMap_Release(&This->IDirectMusicChordMap_iface);
}
static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
@@ -346,17 +315,17 @@ static const IDirectMusicObjectVtbl DirectMusicChordMap_Object_Vtbl = {
/* IDirectMusicChordMapImpl IPersistStream part: */
static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
- return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
+ return IDirectMusicChordMap_QueryInterface(&This->IDirectMusicChordMap_iface, riid, ppobj);
}
static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
- return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
+ return IDirectMusicChordMap_AddRef(&This->IDirectMusicChordMap_iface);
}
static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
- return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
+ return IDirectMusicChordMap_Release(&This->IDirectMusicChordMap_iface);
}
static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
@@ -537,13 +506,13 @@ static const IPersistStreamVtbl DirectMusicChordMap_PersistStream_Vtbl = {
HRESULT WINAPI create_dmchordmap(REFIID lpcGUID, void **ppobj)
{
IDirectMusicChordMapImpl* obj;
-
+ HRESULT hr;
+
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordMapImpl));
if (NULL == obj) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
- obj->UnknownVtbl = &DirectMusicChordMap_Unknown_Vtbl;
obj->IDirectMusicChordMap_iface.lpVtbl = &dmchordmap_vtbl;
obj->ObjectVtbl = &DirectMusicChordMap_Object_Vtbl;
obj->PersistStreamVtbl = &DirectMusicChordMap_PersistStream_Vtbl;
@@ -551,7 +520,11 @@ HRESULT WINAPI create_dmchordmap(REFIID lpcGUID, void **ppobj)
DM_STRUCT_INIT(obj->pDesc);
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
obj->pDesc->guidClass = CLSID_DirectMusicChordMap;
- obj->ref = 0; /* will be inited by QueryInterface */
+ obj->ref = 1;
+
+ DMCOMPOS_LockModule();
+ hr = IDirectMusicChordMap_QueryInterface(&obj->IDirectMusicChordMap_iface, lpcGUID, ppobj);
+ IDirectMusicChordMap_Release(&obj->IDirectMusicChordMap_iface);
- return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
+ return hr;
}
diff --git a/dlls/dmcompos/dmcompos_private.h b/dlls/dmcompos/dmcompos_private.h
index 6f680e5..d7113e5 100644
--- a/dlls/dmcompos/dmcompos_private.h
+++ b/dlls/dmcompos/dmcompos_private.h
@@ -61,8 +61,6 @@ extern HRESULT WINAPI create_dmsignposttrack(REFIID riid, void **ret_iface) DECL
* IDirectMusicChordMapImpl implementation structure
*/
struct IDirectMusicChordMapImpl {
- /* IUnknown fields */
- const IUnknownVtbl *UnknownVtbl;
IDirectMusicChordMap IDirectMusicChordMap_iface;
const IDirectMusicObjectVtbl *ObjectVtbl;
const IPersistStreamVtbl *PersistStreamVtbl;
More information about the wine-cvs
mailing list