Release 1.7.13.
[wine/multimedia.git] / dlls / dmime / dmime_main.c
blobd069a0156987aecb3df4a8944eb877d3b52d182c
1 /* DirectMusicInteractiveEngine Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 * Copyright (C) 2003-2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "dmime_private.h"
22 #include "rpcproxy.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
26 static HINSTANCE instance;
27 LONG DMIME_refCount = 0;
29 typedef struct {
30 IClassFactory IClassFactory_iface;
31 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ret_iface);
32 } IClassFactoryImpl;
34 /******************************************************************
35 * IClassFactory implementation
37 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
39 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
42 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
44 if (ppv == NULL)
45 return E_POINTER;
47 if (IsEqualGUID(&IID_IUnknown, riid))
48 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
49 else if (IsEqualGUID(&IID_IClassFactory, riid))
50 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
51 else {
52 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
53 *ppv = NULL;
54 return E_NOINTERFACE;
57 *ppv = iface;
58 IUnknown_AddRef((IUnknown*)*ppv);
59 return S_OK;
62 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
64 DMIME_LockModule();
66 return 2; /* non-heap based object */
69 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
71 DMIME_UnlockModule();
73 return 1; /* non-heap based object */
76 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
77 REFIID riid, void **ppv)
79 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
81 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
83 if(pUnkOuter)
84 return CLASS_E_NOAGGREGATION;
86 return This->fnCreateInstance(riid, ppv);
89 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
91 TRACE("(%d)\n", dolock);
93 if (dolock)
94 DMIME_LockModule();
95 else
96 DMIME_UnlockModule();
98 return S_OK;
101 static const IClassFactoryVtbl classfactory_vtbl = {
102 ClassFactory_QueryInterface,
103 ClassFactory_AddRef,
104 ClassFactory_Release,
105 ClassFactory_CreateInstance,
106 ClassFactory_LockServer
110 static IClassFactoryImpl Performance_CF = {{&classfactory_vtbl}, create_dmperformance};
111 static IClassFactoryImpl Segment_CF = {{&classfactory_vtbl}, create_dmsegment};
112 static IClassFactoryImpl SegmentState_CF = {{&classfactory_vtbl}, create_dmsegmentstate};
113 static IClassFactoryImpl Graph_CF = {{&classfactory_vtbl}, create_dmgraph};
114 static IClassFactoryImpl TempoTrack_CF = {{&classfactory_vtbl}, create_dmtempotrack};
115 static IClassFactoryImpl SeqTrack_CF = {{&classfactory_vtbl}, create_dmseqtrack};
116 static IClassFactoryImpl SysExTrack_CF = {{&classfactory_vtbl}, create_dmsysextrack};
117 static IClassFactoryImpl TimeSigTrack_CF = {{&classfactory_vtbl}, create_dmtimesigtrack};
118 static IClassFactoryImpl ParamControlTrack_CF = {{&classfactory_vtbl}, create_dmparamcontroltrack};
119 static IClassFactoryImpl MarkerTrack_CF = {{&classfactory_vtbl}, create_dmmarkertrack};
120 static IClassFactoryImpl LyricsTrack_CF = {{&classfactory_vtbl}, create_dmlyricstrack};
121 static IClassFactoryImpl SegTriggerTrack_CF = {{&classfactory_vtbl}, create_dmsegtriggertrack};
122 static IClassFactoryImpl AudioPath_CF = {{&classfactory_vtbl}, create_dmaudiopath};
123 static IClassFactoryImpl WaveTrack_CF = {{&classfactory_vtbl}, create_dmwavetrack};
125 /******************************************************************
126 * DllMain
130 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
131 if (fdwReason == DLL_PROCESS_ATTACH) {
132 instance = hinstDLL;
133 DisableThreadLibraryCalls(hinstDLL);
136 return TRUE;
140 /******************************************************************
141 * DllCanUnloadNow (DMIME.1)
145 HRESULT WINAPI DllCanUnloadNow(void)
147 return DMIME_refCount != 0 ? S_FALSE : S_OK;
151 /******************************************************************
152 * DllGetClassObject (DMIME.@)
156 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
158 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
159 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicPerformance) && IsEqualIID (riid, &IID_IClassFactory)) {
160 *ppv = &Performance_CF;
161 IClassFactory_AddRef((IClassFactory*)*ppv);
162 return S_OK;
163 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegment) && IsEqualIID (riid, &IID_IClassFactory)) {
164 *ppv = &Segment_CF;
165 IClassFactory_AddRef((IClassFactory*)*ppv);
166 return S_OK;
167 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegmentState) && IsEqualIID (riid, &IID_IClassFactory)) {
168 *ppv = &SegmentState_CF;
169 IClassFactory_AddRef((IClassFactory*)*ppv);
170 return S_OK;
171 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicGraph) && IsEqualIID (riid, &IID_IClassFactory)) {
172 *ppv = &Graph_CF;
173 IClassFactory_AddRef((IClassFactory*)*ppv);
174 return S_OK;
175 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTempoTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
176 *ppv = &TempoTrack_CF;
177 IClassFactory_AddRef((IClassFactory*)*ppv);
178 return S_OK;
179 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSeqTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
180 *ppv = &SeqTrack_CF;
181 IClassFactory_AddRef((IClassFactory*)*ppv);
182 return S_OK;
183 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSysExTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
184 *ppv = &SysExTrack_CF;
185 IClassFactory_AddRef((IClassFactory*)*ppv);
186 return S_OK;
187 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTimeSigTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
188 *ppv = &TimeSigTrack_CF;
189 IClassFactory_AddRef((IClassFactory*)*ppv);
190 return S_OK;
191 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicParamControlTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
192 *ppv = &ParamControlTrack_CF;
193 IClassFactory_AddRef((IClassFactory*)*ppv);
194 return S_OK;
195 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMarkerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
196 *ppv = &MarkerTrack_CF;
197 IClassFactory_AddRef((IClassFactory*)*ppv);
198 return S_OK;
199 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLyricsTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
200 *ppv = &LyricsTrack_CF;
201 IClassFactory_AddRef((IClassFactory*)*ppv);
202 return S_OK;
203 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegTriggerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
204 *ppv = &SegTriggerTrack_CF;
205 IClassFactory_AddRef((IClassFactory*)*ppv);
206 return S_OK;
207 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAudioPathConfig) &&
208 IsEqualIID (riid, &IID_IClassFactory)) {
209 *ppv = &AudioPath_CF;
210 IClassFactory_AddRef((IClassFactory*)*ppv);
211 return S_OK;
212 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicWaveTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
213 *ppv = &WaveTrack_CF;
214 IClassFactory_AddRef((IClassFactory*)*ppv);
215 return S_OK;
218 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
219 return CLASS_E_CLASSNOTAVAILABLE;
222 /***********************************************************************
223 * DllRegisterServer (DMIME.@)
225 HRESULT WINAPI DllRegisterServer(void)
227 return __wine_register_resources( instance );
230 /***********************************************************************
231 * DllUnregisterServer (DMIME.@)
233 HRESULT WINAPI DllUnregisterServer(void)
235 return __wine_unregister_resources( instance );