mshtml: Removed no longer used attr_name from event_info_t.
[wine.git] / dlls / dmime / dmime_main.c
blob37302ff0eb6b7fc9a6551e64e8a451f4593c0159
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 <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnt.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winreg.h"
31 #include "objbase.h"
32 #include "rpcproxy.h"
33 #include "initguid.h"
34 #include "dmusici.h"
36 #include "dmime_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
40 static HINSTANCE instance;
41 LONG DMIME_refCount = 0;
43 typedef struct {
44 IClassFactory IClassFactory_iface;
45 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ret_iface);
46 } IClassFactoryImpl;
48 /******************************************************************
49 * IClassFactory implementation
51 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
53 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
56 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
58 if (ppv == NULL)
59 return E_POINTER;
61 if (IsEqualGUID(&IID_IUnknown, riid))
62 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
63 else if (IsEqualGUID(&IID_IClassFactory, riid))
64 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
65 else {
66 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
67 *ppv = NULL;
68 return E_NOINTERFACE;
71 *ppv = iface;
72 IUnknown_AddRef((IUnknown*)*ppv);
73 return S_OK;
76 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
78 DMIME_LockModule();
80 return 2; /* non-heap based object */
83 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
85 DMIME_UnlockModule();
87 return 1; /* non-heap based object */
90 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
91 REFIID riid, void **ppv)
93 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
95 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
97 if(pUnkOuter)
98 return CLASS_E_NOAGGREGATION;
100 return This->fnCreateInstance(riid, ppv);
103 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
105 TRACE("(%d)\n", dolock);
107 if (dolock)
108 DMIME_LockModule();
109 else
110 DMIME_UnlockModule();
112 return S_OK;
115 static const IClassFactoryVtbl classfactory_vtbl = {
116 ClassFactory_QueryInterface,
117 ClassFactory_AddRef,
118 ClassFactory_Release,
119 ClassFactory_CreateInstance,
120 ClassFactory_LockServer
124 static IClassFactoryImpl Performance_CF = {{&classfactory_vtbl}, create_dmperformance};
125 static IClassFactoryImpl Segment_CF = {{&classfactory_vtbl}, create_dmsegment};
126 static IClassFactoryImpl SegmentState_CF = {{&classfactory_vtbl}, create_dmsegmentstate};
127 static IClassFactoryImpl Graph_CF = {{&classfactory_vtbl}, create_dmgraph};
128 static IClassFactoryImpl TempoTrack_CF = {{&classfactory_vtbl}, create_dmtempotrack};
129 static IClassFactoryImpl SeqTrack_CF = {{&classfactory_vtbl}, create_dmseqtrack};
130 static IClassFactoryImpl SysExTrack_CF = {{&classfactory_vtbl}, create_dmsysextrack};
131 static IClassFactoryImpl TimeSigTrack_CF = {{&classfactory_vtbl}, create_dmtimesigtrack};
132 static IClassFactoryImpl ParamControlTrack_CF = {{&classfactory_vtbl}, create_dmparamcontroltrack};
133 static IClassFactoryImpl MarkerTrack_CF = {{&classfactory_vtbl}, create_dmmarkertrack};
134 static IClassFactoryImpl LyricsTrack_CF = {{&classfactory_vtbl}, create_dmlyricstrack};
135 static IClassFactoryImpl SegTriggerTrack_CF = {{&classfactory_vtbl}, create_dmsegtriggertrack};
136 static IClassFactoryImpl AudioPath_CF = {{&classfactory_vtbl}, create_dmaudiopath};
137 static IClassFactoryImpl WaveTrack_CF = {{&classfactory_vtbl}, create_dmwavetrack};
139 /******************************************************************
140 * DllMain
144 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
145 if (fdwReason == DLL_PROCESS_ATTACH) {
146 instance = hinstDLL;
147 DisableThreadLibraryCalls(hinstDLL);
150 return TRUE;
154 /******************************************************************
155 * DllCanUnloadNow (DMIME.1)
159 HRESULT WINAPI DllCanUnloadNow(void)
161 return DMIME_refCount != 0 ? S_FALSE : S_OK;
165 /******************************************************************
166 * DllGetClassObject (DMIME.@)
170 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
172 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
173 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicPerformance) && IsEqualIID (riid, &IID_IClassFactory)) {
174 *ppv = &Performance_CF;
175 IClassFactory_AddRef((IClassFactory*)*ppv);
176 return S_OK;
177 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegment) && IsEqualIID (riid, &IID_IClassFactory)) {
178 *ppv = &Segment_CF;
179 IClassFactory_AddRef((IClassFactory*)*ppv);
180 return S_OK;
181 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegmentState) && IsEqualIID (riid, &IID_IClassFactory)) {
182 *ppv = &SegmentState_CF;
183 IClassFactory_AddRef((IClassFactory*)*ppv);
184 return S_OK;
185 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicGraph) && IsEqualIID (riid, &IID_IClassFactory)) {
186 *ppv = &Graph_CF;
187 IClassFactory_AddRef((IClassFactory*)*ppv);
188 return S_OK;
189 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTempoTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
190 *ppv = &TempoTrack_CF;
191 IClassFactory_AddRef((IClassFactory*)*ppv);
192 return S_OK;
193 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSeqTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
194 *ppv = &SeqTrack_CF;
195 IClassFactory_AddRef((IClassFactory*)*ppv);
196 return S_OK;
197 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSysExTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
198 *ppv = &SysExTrack_CF;
199 IClassFactory_AddRef((IClassFactory*)*ppv);
200 return S_OK;
201 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTimeSigTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
202 *ppv = &TimeSigTrack_CF;
203 IClassFactory_AddRef((IClassFactory*)*ppv);
204 return S_OK;
205 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicParamControlTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
206 *ppv = &ParamControlTrack_CF;
207 IClassFactory_AddRef((IClassFactory*)*ppv);
208 return S_OK;
209 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMarkerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
210 *ppv = &MarkerTrack_CF;
211 IClassFactory_AddRef((IClassFactory*)*ppv);
212 return S_OK;
213 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLyricsTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
214 *ppv = &LyricsTrack_CF;
215 IClassFactory_AddRef((IClassFactory*)*ppv);
216 return S_OK;
217 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegTriggerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
218 *ppv = &SegTriggerTrack_CF;
219 IClassFactory_AddRef((IClassFactory*)*ppv);
220 return S_OK;
221 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAudioPathConfig) &&
222 IsEqualIID (riid, &IID_IClassFactory)) {
223 *ppv = &AudioPath_CF;
224 IClassFactory_AddRef((IClassFactory*)*ppv);
225 return S_OK;
226 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicWaveTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
227 *ppv = &WaveTrack_CF;
228 IClassFactory_AddRef((IClassFactory*)*ppv);
229 return S_OK;
232 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
233 return CLASS_E_CLASSNOTAVAILABLE;
236 /***********************************************************************
237 * DllRegisterServer (DMIME.@)
239 HRESULT WINAPI DllRegisterServer(void)
241 return __wine_register_resources( instance );
244 /***********************************************************************
245 * DllUnregisterServer (DMIME.@)
247 HRESULT WINAPI DllUnregisterServer(void)
249 return __wine_unregister_resources( instance );