winex11.drv: Map coordinates before calling send_mouse_input.
[wine/zf.git] / dlls / dmime / dmime_main.c
blob1749bbe69d6bb66266de2cc02e36e549c4257393
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"
37 #include "dmobject.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
41 static HINSTANCE instance;
42 LONG DMIME_refCount = 0;
44 typedef struct {
45 IClassFactory IClassFactory_iface;
46 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ret_iface);
47 } IClassFactoryImpl;
49 /******************************************************************
50 * IClassFactory implementation
52 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
54 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
57 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
59 if (ppv == NULL)
60 return E_POINTER;
62 if (IsEqualGUID(&IID_IUnknown, riid))
63 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
64 else if (IsEqualGUID(&IID_IClassFactory, riid))
65 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
66 else {
67 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
68 *ppv = NULL;
69 return E_NOINTERFACE;
72 *ppv = iface;
73 IUnknown_AddRef((IUnknown*)*ppv);
74 return S_OK;
77 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
79 DMIME_LockModule();
81 return 2; /* non-heap based object */
84 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
86 DMIME_UnlockModule();
88 return 1; /* non-heap based object */
91 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
92 REFIID riid, void **ppv)
94 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
96 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
98 if(pUnkOuter)
99 return CLASS_E_NOAGGREGATION;
101 return This->fnCreateInstance(riid, ppv);
104 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
106 TRACE("(%d)\n", dolock);
108 if (dolock)
109 DMIME_LockModule();
110 else
111 DMIME_UnlockModule();
113 return S_OK;
116 static const IClassFactoryVtbl classfactory_vtbl = {
117 ClassFactory_QueryInterface,
118 ClassFactory_AddRef,
119 ClassFactory_Release,
120 ClassFactory_CreateInstance,
121 ClassFactory_LockServer
125 static IClassFactoryImpl Performance_CF = {{&classfactory_vtbl}, create_dmperformance};
126 static IClassFactoryImpl Segment_CF = {{&classfactory_vtbl}, create_dmsegment};
127 static IClassFactoryImpl SegmentState_CF = {{&classfactory_vtbl}, create_dmsegmentstate};
128 static IClassFactoryImpl Graph_CF = {{&classfactory_vtbl}, create_dmgraph};
129 static IClassFactoryImpl TempoTrack_CF = {{&classfactory_vtbl}, create_dmtempotrack};
130 static IClassFactoryImpl SeqTrack_CF = {{&classfactory_vtbl}, create_dmseqtrack};
131 static IClassFactoryImpl SysExTrack_CF = {{&classfactory_vtbl}, create_dmsysextrack};
132 static IClassFactoryImpl TimeSigTrack_CF = {{&classfactory_vtbl}, create_dmtimesigtrack};
133 static IClassFactoryImpl ParamControlTrack_CF = {{&classfactory_vtbl}, create_dmparamcontroltrack};
134 static IClassFactoryImpl MarkerTrack_CF = {{&classfactory_vtbl}, create_dmmarkertrack};
135 static IClassFactoryImpl LyricsTrack_CF = {{&classfactory_vtbl}, create_dmlyricstrack};
136 static IClassFactoryImpl SegTriggerTrack_CF = {{&classfactory_vtbl}, create_dmsegtriggertrack};
137 static IClassFactoryImpl AudioPath_CF = {{&classfactory_vtbl}, create_dmaudiopath};
138 static IClassFactoryImpl WaveTrack_CF = {{&classfactory_vtbl}, create_dmwavetrack};
140 /******************************************************************
141 * DllMain
145 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
146 if (fdwReason == DLL_PROCESS_ATTACH) {
147 instance = hinstDLL;
148 DisableThreadLibraryCalls(hinstDLL);
151 return TRUE;
155 /******************************************************************
156 * DllCanUnloadNow (DMIME.1)
160 HRESULT WINAPI DllCanUnloadNow(void)
162 return DMIME_refCount != 0 ? S_FALSE : S_OK;
166 /******************************************************************
167 * DllGetClassObject (DMIME.@)
171 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
173 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
174 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicPerformance) && IsEqualIID (riid, &IID_IClassFactory)) {
175 *ppv = &Performance_CF;
176 IClassFactory_AddRef((IClassFactory*)*ppv);
177 return S_OK;
178 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegment) && IsEqualIID (riid, &IID_IClassFactory)) {
179 *ppv = &Segment_CF;
180 IClassFactory_AddRef((IClassFactory*)*ppv);
181 return S_OK;
182 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegmentState) && IsEqualIID (riid, &IID_IClassFactory)) {
183 *ppv = &SegmentState_CF;
184 IClassFactory_AddRef((IClassFactory*)*ppv);
185 return S_OK;
186 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicGraph) && IsEqualIID (riid, &IID_IClassFactory)) {
187 *ppv = &Graph_CF;
188 IClassFactory_AddRef((IClassFactory*)*ppv);
189 return S_OK;
190 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTempoTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
191 *ppv = &TempoTrack_CF;
192 IClassFactory_AddRef((IClassFactory*)*ppv);
193 return S_OK;
194 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSeqTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
195 *ppv = &SeqTrack_CF;
196 IClassFactory_AddRef((IClassFactory*)*ppv);
197 return S_OK;
198 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSysExTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
199 *ppv = &SysExTrack_CF;
200 IClassFactory_AddRef((IClassFactory*)*ppv);
201 return S_OK;
202 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTimeSigTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
203 *ppv = &TimeSigTrack_CF;
204 IClassFactory_AddRef((IClassFactory*)*ppv);
205 return S_OK;
206 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicParamControlTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
207 *ppv = &ParamControlTrack_CF;
208 IClassFactory_AddRef((IClassFactory*)*ppv);
209 return S_OK;
210 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMarkerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
211 *ppv = &MarkerTrack_CF;
212 IClassFactory_AddRef((IClassFactory*)*ppv);
213 return S_OK;
214 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLyricsTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
215 *ppv = &LyricsTrack_CF;
216 IClassFactory_AddRef((IClassFactory*)*ppv);
217 return S_OK;
218 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegTriggerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
219 *ppv = &SegTriggerTrack_CF;
220 IClassFactory_AddRef((IClassFactory*)*ppv);
221 return S_OK;
222 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAudioPathConfig) &&
223 IsEqualIID (riid, &IID_IClassFactory)) {
224 *ppv = &AudioPath_CF;
225 IClassFactory_AddRef((IClassFactory*)*ppv);
226 return S_OK;
227 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicWaveTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
228 *ppv = &WaveTrack_CF;
229 IClassFactory_AddRef((IClassFactory*)*ppv);
230 return S_OK;
233 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
234 return CLASS_E_CLASSNOTAVAILABLE;
237 /***********************************************************************
238 * DllRegisterServer (DMIME.@)
240 HRESULT WINAPI DllRegisterServer(void)
242 return __wine_register_resources( instance );
245 /***********************************************************************
246 * DllUnregisterServer (DMIME.@)
248 HRESULT WINAPI DllUnregisterServer(void)
250 return __wine_unregister_resources( instance );