1 /* DirectMusicBand Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmband_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
24 LONG DMBAND_refCount = 0;
27 const IClassFactoryVtbl *lpVtbl;
30 /******************************************************************
31 * DirectMusicBand ClassFactory
34 static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
35 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
37 if (ppobj == NULL) return E_POINTER;
42 static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
45 return 2; /* non-heap based object */
48 static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
49 DMBAND_UnlockModule();
51 return 1; /* non-heap based object */
54 static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
55 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
57 return DMUSIC_CreateDirectMusicBandImpl (riid, ppobj, pOuter);
60 static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
61 TRACE("(%d)\n", dolock);
66 DMBAND_UnlockModule();
71 static const IClassFactoryVtbl BandCF_Vtbl = {
72 BandCF_QueryInterface,
75 BandCF_CreateInstance,
79 static IClassFactoryImpl Band_CF = {&BandCF_Vtbl};
82 /******************************************************************
83 * DirectMusicBandTrack ClassFactory
86 static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
87 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
89 if (ppobj == NULL) return E_POINTER;
94 static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
97 return 2; /* non-heap based object */
100 static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
101 DMBAND_UnlockModule();
103 return 1; /* non-heap based object */
106 static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
107 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
109 return DMUSIC_CreateDirectMusicBandTrack (riid, ppobj, pOuter);
112 static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
113 TRACE("(%d)\n", dolock);
118 DMBAND_UnlockModule();
123 static const IClassFactoryVtbl BandTrackCF_Vtbl = {
124 BandTrackCF_QueryInterface,
127 BandTrackCF_CreateInstance,
128 BandTrackCF_LockServer
131 static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl};
133 /******************************************************************
138 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
139 if (fdwReason == DLL_PROCESS_ATTACH) {
140 DisableThreadLibraryCalls(hinstDLL);
141 /* FIXME: Initialisation */
142 } else if (fdwReason == DLL_PROCESS_DETACH) {
150 /******************************************************************
151 * DllCanUnloadNow (DMBAND.@)
155 HRESULT WINAPI DllCanUnloadNow(void)
157 return DMBAND_refCount != 0 ? S_FALSE : S_OK;
161 /******************************************************************
162 * DllGetClassObject (DMBAND.@)
166 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
168 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
170 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
172 IClassFactory_AddRef((IClassFactory*)*ppv);
174 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
175 *ppv = &BandTrack_CF;
176 IClassFactory_AddRef((IClassFactory*)*ppv);
180 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
181 return CLASS_E_CLASSNOTAVAILABLE;