#include <stdio.h>
#include "dmusic_private.h"
+#include "rpcproxy.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
+static HINSTANCE instance;
LONG DMUSIC_refCount = 0;
typedef struct {
- const IClassFactoryVtbl *lpVtbl;
+ IClassFactory IClassFactory_iface;
+ HRESULT (WINAPI *fnCreateInstance)(REFIID riid, void **ppv, IUnknown *pUnkOuter);
} IClassFactoryImpl;
/******************************************************************
- * DirectMusic ClassFactory
+ * IClassFactory implementation
*/
-static HRESULT WINAPI DirectMusicCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
-
- if (ppobj == NULL) return E_POINTER;
-
- return E_NOINTERFACE;
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+ return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
}
-static ULONG WINAPI DirectMusicCF_AddRef(LPCLASSFACTORY iface) {
- DMUSIC_LockModule();
-
- return 2; /* non-heap based object */
+static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
+{
+ if (ppv == NULL)
+ return E_POINTER;
+
+ if (IsEqualGUID(&IID_IUnknown, riid))
+ TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
+ else if (IsEqualGUID(&IID_IClassFactory, riid))
+ TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
+ else {
+ FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+
+ *ppv = iface;
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
}
-static ULONG WINAPI DirectMusicCF_Release(LPCLASSFACTORY iface) {
- DMUSIC_UnlockModule();
-
- return 1; /* non-heap based object */
-}
+static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
+{
+ DMUSIC_LockModule();
-static HRESULT WINAPI DirectMusicCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
- TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
- return DMUSIC_CreateDirectMusicImpl (riid, ppobj, pOuter);
+ return 2; /* non-heap based object */
}
-static HRESULT WINAPI DirectMusicCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%d)\n", dolock);
-
- if (dolock)
- DMUSIC_LockModule();
- else
- DMUSIC_UnlockModule();
-
- return S_OK;
-}
-
-static const IClassFactoryVtbl DirectMusicCF_Vtbl = {
- DirectMusicCF_QueryInterface,
- DirectMusicCF_AddRef,
- DirectMusicCF_Release,
- DirectMusicCF_CreateInstance,
- DirectMusicCF_LockServer
-};
-
-static IClassFactoryImpl DirectMusic_CF = {&DirectMusicCF_Vtbl};
-
-/******************************************************************
- * DirectMusicCollection ClassFactory
- */
-static HRESULT WINAPI CollectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
+static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
+{
+ DMUSIC_UnlockModule();
- if (ppobj == NULL) return E_POINTER;
-
- return E_NOINTERFACE;
+ return 1; /* non-heap based object */
}
-static ULONG WINAPI CollectionCF_AddRef(LPCLASSFACTORY iface) {
- DMUSIC_LockModule();
-
- return 2; /* non-heap based object */
-}
+static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
+ REFIID riid, void **ppv)
+{
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
-static ULONG WINAPI CollectionCF_Release(LPCLASSFACTORY iface) {
- DMUSIC_UnlockModule();
+ TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
- return 1; /* non-heap based object */
+ return This->fnCreateInstance(riid, ppv, pUnkOuter);
}
-static HRESULT WINAPI CollectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
- TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
- return DMUSIC_CreateDirectMusicCollectionImpl (riid, ppobj, pOuter);
-}
+static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
+{
+ TRACE("(%d)\n", dolock);
-static HRESULT WINAPI CollectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%d)\n", dolock);
+ if (dolock)
+ DMUSIC_LockModule();
+ else
+ DMUSIC_UnlockModule();
- if (dolock)
- DMUSIC_LockModule();
- else
- DMUSIC_UnlockModule();
-
- return S_OK;
+ return S_OK;
}
-static const IClassFactoryVtbl CollectionCF_Vtbl = {
- CollectionCF_QueryInterface,
- CollectionCF_AddRef,
- CollectionCF_Release,
- CollectionCF_CreateInstance,
- CollectionCF_LockServer
+static const IClassFactoryVtbl classfactory_vtbl = {
+ ClassFactory_QueryInterface,
+ ClassFactory_AddRef,
+ ClassFactory_Release,
+ ClassFactory_CreateInstance,
+ ClassFactory_LockServer
};
-static IClassFactoryImpl Collection_CF = {&CollectionCF_Vtbl};
+static IClassFactoryImpl DirectMusic_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicImpl};
+static IClassFactoryImpl Collection_CF = {{&classfactory_vtbl},
+ DMUSIC_CreateDirectMusicCollectionImpl};
/******************************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_ATTACH) {
+ instance = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
/* FIXME: Initialisation */
} else if (fdwReason == DLL_PROCESS_DETACH) {
return CLASS_E_CLASSNOTAVAILABLE;
}
+/***********************************************************************
+ * DllRegisterServer (DMUSIC.@)
+ */
+HRESULT WINAPI DllRegisterServer(void)
+{
+ return __wine_register_resources( instance );
+}
+
+/***********************************************************************
+ * DllUnregisterServer (DMUSIC.@)
+ */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+ return __wine_unregister_resources( instance );
+}
/******************************************************************
* Helper functions
*
*/
/* dwPatch from MIDILOCALE */
-DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale) {
+DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) {
DWORD dwPatch = 0;
if (!pLocale) return 0;
dwPatch |= (pLocale->ulBank & F_INSTRUMENT_DRUMS); /* set drum bit */
return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
-/* dump whole DMUS_OBJECTDESC struct */
-const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
- if (pDesc) {
- char buffer[1024] = "", *ptr = &buffer[0];
-
- ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
- ptr += sprintf(ptr, " - dwSize = %d\n", pDesc->dwSize);
- ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
- if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
- if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
- if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
- if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
- if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
- if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
- if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
- if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = 0x%s\n - pbMemData = %p\n",
- wine_dbgstr_longlong(pDesc->llMemLength), pDesc->pbMemData);
- if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
-
- return wine_dbg_sprintf("%s", buffer);
- } else {
- return wine_dbg_sprintf("(NULL)");
- }
+/* Dump whole DMUS_OBJECTDESC struct */
+void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc)
+{
+ TRACE("DMUS_OBJECTDESC (%p):\n", desc);
+ TRACE(" - dwSize = %d\n", desc->dwSize);
+ TRACE(" - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (desc->dwValidData));
+ if (desc->dwValidData & DMUS_OBJ_CLASS) TRACE(" - guidClass = %s\n", debugstr_dmguid(&desc->guidClass));
+ if (desc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guidObject = %s\n", debugstr_guid(&desc->guidObject));
+ if (desc->dwValidData & DMUS_OBJ_DATE) TRACE(" - ftDate = FIXME\n");
+ if (desc->dwValidData & DMUS_OBJ_VERSION) TRACE(" - vVersion = %s\n", debugstr_dmversion(&desc->vVersion));
+ if (desc->dwValidData & DMUS_OBJ_NAME) TRACE(" - wszName = %s\n", debugstr_w(desc->wszName));
+ if (desc->dwValidData & DMUS_OBJ_CATEGORY) TRACE(" - wszCategory = %s\n", debugstr_w(desc->wszCategory));
+ if (desc->dwValidData & DMUS_OBJ_FILENAME) TRACE(" - wszFileName = %s\n", debugstr_w(desc->wszFileName));
+ if (desc->dwValidData & DMUS_OBJ_MEMORY) TRACE(" - llMemLength = 0x%s\n - pbMemData = %p\n",
+ wine_dbgstr_longlong(desc->llMemLength), desc->pbMemData);
+ if (desc->dwValidData & DMUS_OBJ_STREAM) TRACE(" - pStream = %p\n", desc->pStream);
+}
+
+/* Dump DMUS_PORTPARAMS flags */
+static const char* debugstr_DMUS_PORTPARAMS_FLAGS(DWORD flagmask)
+{
+ static const flag_info flags[] = {
+ FE(DMUS_PORTPARAMS_VOICES),
+ FE(DMUS_PORTPARAMS_CHANNELGROUPS),
+ FE(DMUS_PORTPARAMS_AUDIOCHANNELS),
+ FE(DMUS_PORTPARAMS_SAMPLERATE),
+ FE(DMUS_PORTPARAMS_EFFECTS),
+ FE(DMUS_PORTPARAMS_SHARE)
+ };
+ return debugstr_flags(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
+}
+
+/* Dump whole DMUS_PORTPARAMS struct */
+void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params)
+{
+ TRACE("DMUS_PORTPARAMS (%p):\n", params);
+ TRACE(" - dwSize = %d\n", params->dwSize);
+ TRACE(" - dwValidParams = %s\n", debugstr_DMUS_PORTPARAMS_FLAGS(params->dwValidParams));
+ if (params->dwValidParams & DMUS_PORTPARAMS_VOICES) TRACE(" - dwVoices = %u\n", params->dwVoices);
+ if (params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) TRACE(" - dwChannelGroup = %u\n", params->dwChannelGroups);
+ if (params->dwValidParams & DMUS_PORTPARAMS_AUDIOCHANNELS) TRACE(" - dwAudioChannels = %u\n", params->dwAudioChannels);
+ if (params->dwValidParams & DMUS_PORTPARAMS_SAMPLERATE) TRACE(" - dwSampleRate = %u\n", params->dwSampleRate);
+ if (params->dwValidParams & DMUS_PORTPARAMS_EFFECTS) TRACE(" - dwEffectFlags = %x\n", params->dwEffectFlags);
+ if (params->dwValidParams & DMUS_PORTPARAMS_SHARE) TRACE(" - fShare = %u\n", params->fShare);
}