2004-05-13 00:00:22 +00:00
|
|
|
/* IDirectMusicLoaderCF
|
|
|
|
* IDirectMusicContainerCF
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Rok Mandeljc
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 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 Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-05-13 00:00:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dmloader_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicLoaderCF implementation
|
|
|
|
*/
|
2006-06-10 09:56:03 +00:00
|
|
|
static ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface);
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectMusicLoaderCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
|
|
|
|
if (IsEqualIID (riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID (riid, &IID_IClassFactory)) {
|
|
|
|
IDirectMusicLoaderCF_AddRef (iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN(": not found\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
|
2006-10-12 19:33:59 +00:00
|
|
|
TRACE("(%p): AddRef from %d\n", This, This->dwRef);
|
2004-05-13 00:00:22 +00:00
|
|
|
return InterlockedIncrement (&This->dwRef);
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static ULONG WINAPI IDirectMusicLoaderCF_Release (LPCLASSFACTORY iface) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
|
|
|
|
DWORD dwRef = InterlockedDecrement (&This->dwRef);
|
2006-10-12 19:33:59 +00:00
|
|
|
TRACE("(%p): ReleaseRef to %d\n", This, dwRef);
|
2004-05-13 00:00:22 +00:00
|
|
|
if (dwRef == 0) {
|
|
|
|
HeapFree(GetProcessHeap (), 0, This);
|
|
|
|
/* decrease number of instances */
|
|
|
|
InterlockedDecrement(&dwDirectMusicLoader);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dwRef;
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicLoaderCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
|
|
|
|
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
|
|
|
|
if (pOuter) {
|
|
|
|
ERR(": pOuter should be NULL\n");
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DMUSIC_CreateDirectMusicLoaderImpl (riid, ppobj, pOuter);
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicLoaderCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
TRACE("(%p, %d)\n", This, dolock);
|
2004-12-09 14:07:59 +00:00
|
|
|
if (dolock)
|
2004-05-13 00:00:22 +00:00
|
|
|
InterlockedIncrement (&dwDirectMusicLoader);
|
|
|
|
else
|
|
|
|
InterlockedDecrement (&dwDirectMusicLoader);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IClassFactoryVtbl DirectMusicLoaderCF_Vtbl = {
|
2004-05-13 00:00:22 +00:00
|
|
|
IDirectMusicLoaderCF_QueryInterface,
|
|
|
|
IDirectMusicLoaderCF_AddRef,
|
|
|
|
IDirectMusicLoaderCF_Release,
|
|
|
|
IDirectMusicLoaderCF_CreateInstance,
|
|
|
|
IDirectMusicLoaderCF_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
|
|
|
|
IDirectMusicLoaderCF *obj;
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
|
|
|
|
obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderCF));
|
|
|
|
if (NULL == obj) {
|
|
|
|
*ppobj = (LPCLASSFACTORY)NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
obj->lpVtbl = &DirectMusicLoaderCF_Vtbl;
|
|
|
|
obj->dwRef = 0; /* will be inited with QueryInterface */
|
|
|
|
|
|
|
|
/* increase number of instances */
|
|
|
|
InterlockedIncrement (&dwDirectMusicLoader);
|
|
|
|
|
|
|
|
return IDirectMusicLoaderCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicContainerCF implementation
|
|
|
|
*/
|
2006-06-10 09:56:03 +00:00
|
|
|
static ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface);
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectMusicContainerCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
|
|
|
|
if (IsEqualIID (riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID (riid, &IID_IClassFactory)) {
|
|
|
|
IDirectMusicContainerCF_AddRef (iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN(": not found\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
|
2006-10-12 19:33:59 +00:00
|
|
|
TRACE("(%p): AddRef from %d\n", This, This->dwRef);
|
2004-05-13 00:00:22 +00:00
|
|
|
return InterlockedIncrement (&This->dwRef);
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static ULONG WINAPI IDirectMusicContainerCF_Release (LPCLASSFACTORY iface) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
|
|
|
|
DWORD dwRef = InterlockedDecrement (&This->dwRef);
|
2006-10-12 19:33:59 +00:00
|
|
|
TRACE("(%p): ReleaseRef to %d\n", This, dwRef);
|
2004-05-13 00:00:22 +00:00
|
|
|
if (dwRef == 0) {
|
|
|
|
HeapFree(GetProcessHeap (), 0, This);
|
|
|
|
/* decrease number of instances */
|
|
|
|
InterlockedDecrement(&dwDirectMusicContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dwRef;
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicContainerCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
|
|
|
|
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
|
|
|
|
if (pOuter) {
|
|
|
|
ERR(": pOuter should be NULL\n");
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DMUSIC_CreateDirectMusicContainerImpl (riid, ppobj, pOuter);
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:03 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicContainerCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
|
2004-09-06 20:34:29 +00:00
|
|
|
IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
|
2004-05-13 00:00:22 +00:00
|
|
|
TRACE("(%p, %d)\n", This, dolock);
|
2004-12-09 14:07:59 +00:00
|
|
|
if (dolock)
|
2004-05-13 00:00:22 +00:00
|
|
|
InterlockedIncrement (&dwDirectMusicContainer);
|
|
|
|
else
|
|
|
|
InterlockedDecrement (&dwDirectMusicContainer);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IClassFactoryVtbl DirectMusicContainerCF_Vtbl = {
|
2004-05-13 00:00:22 +00:00
|
|
|
IDirectMusicContainerCF_QueryInterface,
|
|
|
|
IDirectMusicContainerCF_AddRef,
|
|
|
|
IDirectMusicContainerCF_Release,
|
|
|
|
IDirectMusicContainerCF_CreateInstance,
|
|
|
|
IDirectMusicContainerCF_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT WINAPI DMUSIC_CreateDirectMusicContainerCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
|
|
|
|
IDirectMusicContainerCF *obj;
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
|
|
|
|
obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerCF));
|
|
|
|
if (NULL == obj) {
|
|
|
|
*ppobj = (LPCLASSFACTORY)NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
obj->lpVtbl = &DirectMusicContainerCF_Vtbl;
|
|
|
|
obj->dwRef = 0; /* will be inited with QueryInterface */
|
|
|
|
|
|
|
|
/* increase number of instances */
|
|
|
|
InterlockedIncrement (&dwDirectMusicContainer);
|
|
|
|
|
|
|
|
return IDirectMusicContainerCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);
|
|
|
|
}
|