[PATCH 1/2] dmusic: Move IDirectMusicDownloadedInstrument to port.c since it is port dependant and perform COM cleanup.

Christian Costa titan.costa at gmail.com
Mon Dec 24 02:46:10 CST 2012


---
 dlls/dmusic/Makefile.in            |    1 
 dlls/dmusic/dmusic_private.h       |    9 ++--
 dlls/dmusic/downloadedinstrument.c |   88 ------------------------------------
 dlls/dmusic/port.c                 |   78 ++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+), 95 deletions(-)
 delete mode 100644 dlls/dmusic/downloadedinstrument.c

diff --git a/dlls/dmusic/Makefile.in b/dlls/dmusic/Makefile.in
index 7522194..46aed59 100644
--- a/dlls/dmusic/Makefile.in
+++ b/dlls/dmusic/Makefile.in
@@ -8,7 +8,6 @@ C_SRCS = \
 	dmusic.c \
 	dmusic_main.c \
 	download.c \
-	downloadedinstrument.c \
 	instrument.c \
 	port.c
 
diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h
index 3e5c6c2..1872177 100644
--- a/dlls/dmusic/dmusic_private.h
+++ b/dlls/dmusic/dmusic_private.h
@@ -95,7 +95,6 @@ extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LP
 
 /* Internal */
 extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
-extern HRESULT DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
 extern HRESULT DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
 extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
 extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
@@ -136,11 +135,11 @@ struct IDirectMusicBufferImpl {
  * IDirectMusicDownloadedInstrumentImpl implementation structure
  */
 struct IDirectMusicDownloadedInstrumentImpl {
-  /* IUnknown fields */
-  const IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
-  LONG           ref;
+    /* IUnknown fields */
+    IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface;
+    LONG ref;
 
-  /* IDirectMusicDownloadedInstrumentImpl fields */
+    /* IDirectMusicDownloadedInstrumentImpl fields */
 };
 
 /*****************************************************************************
diff --git a/dlls/dmusic/downloadedinstrument.c b/dlls/dmusic/downloadedinstrument.c
deleted file mode 100644
index b64d8ac..0000000
--- a/dlls/dmusic/downloadedinstrument.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* IDirectMusicDownloadedInstrument Implementation
- *
- * Copyright (C) 2003-2004 Rok Mandeljc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "dmusic_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
-
-/* IDirectMusicDownloadedInstrumentImpl IUnknown part: */
-static HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface, REFIID riid, LPVOID *ppobj) {
-	IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
-	TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
-
-	if (IsEqualIID (riid, &IID_IUnknown)
-		|| IsEqualIID (riid, &IID_IDirectMusicDownloadedInstrument)
-		|| IsEqualIID (riid, &IID_IDirectMusicDownloadedInstrument8)) {
-		IUnknown_AddRef(iface);
-		*ppobj = This;
-		return S_OK;
-	}
-	WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
-	return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) {
-	IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
-	ULONG refCount = InterlockedIncrement(&This->ref);
-
-	TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
-
-	DMUSIC_LockModule();
-
-	return refCount;
-}
-
-static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) {
-	IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface;
-	ULONG refCount = InterlockedDecrement(&This->ref);
-
-	TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
-
-	if (!refCount) {
-		HeapFree(GetProcessHeap(), 0, This);
-	}
-
-	DMUSIC_UnlockModule();
-	
-	return refCount;
-}
-
-/* IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrument part: */
-/* none at this time */
-
-static const IDirectMusicDownloadedInstrumentVtbl DirectMusicDownloadedInstrument_Vtbl = {
-	IDirectMusicDownloadedInstrumentImpl_QueryInterface,
-	IDirectMusicDownloadedInstrumentImpl_AddRef,
-	IDirectMusicDownloadedInstrumentImpl_Release
-};
-
-/* for ClassFactory */
-HRESULT DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
-	IDirectMusicDownloadedInstrumentImpl* dmdlinst;
-	
-	dmdlinst = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicDownloadedInstrumentImpl));
-	if (NULL == dmdlinst) {
-		*ppobj = NULL;
-		return E_OUTOFMEMORY;
-	}
-	dmdlinst->lpVtbl = &DirectMusicDownloadedInstrument_Vtbl;
-	dmdlinst->ref = 0; /* will be inited by QueryInterface */
-	
-	return IDirectMusicDownloadedInstrumentImpl_QueryInterface ((LPDIRECTMUSICDOWNLOADEDINSTRUMENT)dmdlinst, lpcGUID, ppobj);	
-}
diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c
index b6489a7..eb139ca 100644
--- a/dlls/dmusic/port.c
+++ b/dlls/dmusic/port.c
@@ -23,6 +23,11 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
 
+static inline IDirectMusicDownloadedInstrumentImpl* impl_from_IDirectMusicDownloadedInstrument(IDirectMusicDownloadedInstrument *iface)
+{
+    return CONTAINING_RECORD(iface, IDirectMusicDownloadedInstrumentImpl, IDirectMusicDownloadedInstrument_iface);
+}
+
 static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicPort(IDirectMusicPort *iface)
 {
     return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicPort_iface);
@@ -38,6 +43,77 @@ static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicThru(IDirectMus
     return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicThru_iface);
 }
 
+/* IDirectMusicDownloadedInstrument IUnknown part follows: */
+static HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface(IDirectMusicDownloadedInstrument *iface, REFIID riid, VOID **ret_iface)
+{
+    TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
+
+    if (IsEqualIID(riid, &IID_IUnknown) ||
+        IsEqualIID(riid, &IID_IDirectMusicDownloadedInstrument) ||
+        IsEqualIID(riid, &IID_IDirectMusicDownloadedInstrument8))
+    {
+        IDirectMusicDownloadedInstrument_AddRef(iface);
+        *ret_iface = iface;
+        return S_OK;
+    }
+
+    WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef(LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+    IDirectMusicDownloadedInstrumentImpl *This = impl_from_IDirectMusicDownloadedInstrument(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p)->(): new ref = %u\n", iface, ref);
+
+    DMUSIC_LockModule();
+
+    return ref;
+}
+
+static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release(LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface)
+{
+    IDirectMusicDownloadedInstrumentImpl *This = impl_from_IDirectMusicDownloadedInstrument(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p)->(): new ref = %u\n", iface, ref);
+
+    if (!ref)
+        HeapFree(GetProcessHeap(), 0, This);
+
+    DMUSIC_UnlockModule();
+
+    return ref;
+}
+
+static const IDirectMusicDownloadedInstrumentVtbl DirectMusicDownloadedInstrument_Vtbl = {
+    IDirectMusicDownloadedInstrumentImpl_QueryInterface,
+    IDirectMusicDownloadedInstrumentImpl_AddRef,
+    IDirectMusicDownloadedInstrumentImpl_Release
+};
+
+HRESULT DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(IDirectMusicDownloadedInstrument **instrument)
+{
+    IDirectMusicDownloadedInstrumentImpl *object;
+
+    object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
+    if (!object)
+    {
+        *instrument = NULL;
+        return E_OUTOFMEMORY;
+    }
+
+    object->IDirectMusicDownloadedInstrument_iface.lpVtbl = &DirectMusicDownloadedInstrument_Vtbl;
+    object->ref = 1;
+
+    *instrument = &object->IDirectMusicDownloadedInstrument_iface;
+
+    return S_OK;
+}
+
 /* SynthPortImpl IDirectMusicPort IUnknown part follows: */
 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_QueryInterface(LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ret_iface)
 {
@@ -157,7 +233,7 @@ static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_DownloadInstrument(LPDIRECT
     if (!instrument || !downloaded_instrument || (num_note_ranges && !note_ranges))
         return E_POINTER;
 
-    return DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(&IID_IDirectMusicDownloadedInstrument, (LPVOID*)downloaded_instrument, NULL);
+    return DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(downloaded_instrument);
 }
 
 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_UnloadInstrument(LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *downloaded_instrument)




More information about the wine-patches mailing list