makefiles: Add support for Automake-style silent make rules.
[wine.git] / dlls / dmsynth / dmsynth_main.c
blobd6718a27213f1eb7f2e6616995ddaefe9df8fb74
1 /* DirectMusicSynthesizer 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
21 #include <stdio.h>
23 #include "dmsynth_private.h"
24 #include "rpcproxy.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
28 static HINSTANCE instance;
29 LONG DMSYNTH_refCount = 0;
31 typedef struct {
32 IClassFactory IClassFactory_iface;
33 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ppv);
34 } IClassFactoryImpl;
36 /******************************************************************
37 * IClassFactory implementation
39 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
41 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
44 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
46 if (ppv == NULL)
47 return E_POINTER;
49 if (IsEqualGUID(&IID_IUnknown, riid))
50 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
51 else if (IsEqualGUID(&IID_IClassFactory, riid))
52 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
53 else {
54 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
55 *ppv = NULL;
56 return E_NOINTERFACE;
59 *ppv = iface;
60 IUnknown_AddRef((IUnknown*)*ppv);
61 return S_OK;
64 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
66 DMSYNTH_LockModule();
68 return 2; /* non-heap based object */
71 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
73 DMSYNTH_UnlockModule();
75 return 1; /* non-heap based object */
78 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
79 REFIID riid, void **ppv)
81 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
83 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
85 if (pUnkOuter)
86 return CLASS_E_NOAGGREGATION;
88 return This->fnCreateInstance(riid, ppv);
91 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
93 TRACE("(%d)\n", dolock);
95 if (dolock)
96 DMSYNTH_LockModule();
97 else
98 DMSYNTH_UnlockModule();
100 return S_OK;
103 static const IClassFactoryVtbl classfactory_vtbl = {
104 ClassFactory_QueryInterface,
105 ClassFactory_AddRef,
106 ClassFactory_Release,
107 ClassFactory_CreateInstance,
108 ClassFactory_LockServer
111 static IClassFactoryImpl Synth_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicSynthImpl};
112 static IClassFactoryImpl SynthSink_CF = {{&classfactory_vtbl},
113 DMUSIC_CreateDirectMusicSynthSinkImpl};
115 /******************************************************************
116 * DllMain
120 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
121 if (fdwReason == DLL_PROCESS_ATTACH) {
122 instance = hinstDLL;
123 DisableThreadLibraryCalls(hinstDLL);
126 return TRUE;
130 /******************************************************************
131 * DllCanUnloadNow (DMSYNTH.@)
135 HRESULT WINAPI DllCanUnloadNow(void)
137 return DMSYNTH_refCount != 0 ? S_FALSE : S_OK;
141 /******************************************************************
142 * DllGetClassObject (DMSYNTH.@)
146 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
148 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
150 if (IsEqualCLSID(rclsid, &CLSID_DirectMusicSynth) && IsEqualIID(riid, &IID_IClassFactory)) {
151 *ppv = &Synth_CF;
152 IClassFactory_AddRef((IClassFactory*)*ppv);
153 return S_OK;
154 } else if (IsEqualCLSID(rclsid, &CLSID_DirectMusicSynthSink) && IsEqualIID(riid, &IID_IClassFactory)) {
155 *ppv = &SynthSink_CF;
156 IClassFactory_AddRef((IClassFactory*)*ppv);
157 return S_OK;
160 WARN("(%s,%s,%p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
161 return CLASS_E_CLASSNOTAVAILABLE;
164 /***********************************************************************
165 * DllRegisterServer (DMSYNTH.@)
167 HRESULT WINAPI DllRegisterServer(void)
169 return __wine_register_resources( instance );
172 /***********************************************************************
173 * DllUnregisterServer (DMSYNTH.@)
175 HRESULT WINAPI DllUnregisterServer(void)
177 return __wine_unregister_resources( instance );
180 /******************************************************************
181 * Helper functions
186 /* returns name of given GUID */
187 const char *debugstr_dmguid (const GUID *id) {
188 static const guid_info guids[] = {
189 /* CLSIDs */
190 GE(CLSID_AudioVBScript),
191 GE(CLSID_DirectMusic),
192 GE(CLSID_DirectMusicAudioPathConfig),
193 GE(CLSID_DirectMusicAuditionTrack),
194 GE(CLSID_DirectMusicBand),
195 GE(CLSID_DirectMusicBandTrack),
196 GE(CLSID_DirectMusicChordMapTrack),
197 GE(CLSID_DirectMusicChordMap),
198 GE(CLSID_DirectMusicChordTrack),
199 GE(CLSID_DirectMusicCollection),
200 GE(CLSID_DirectMusicCommandTrack),
201 GE(CLSID_DirectMusicComposer),
202 GE(CLSID_DirectMusicContainer),
203 GE(CLSID_DirectMusicGraph),
204 GE(CLSID_DirectMusicLoader),
205 GE(CLSID_DirectMusicLyricsTrack),
206 GE(CLSID_DirectMusicMarkerTrack),
207 GE(CLSID_DirectMusicMelodyFormulationTrack),
208 GE(CLSID_DirectMusicMotifTrack),
209 GE(CLSID_DirectMusicMuteTrack),
210 GE(CLSID_DirectMusicParamControlTrack),
211 GE(CLSID_DirectMusicPatternTrack),
212 GE(CLSID_DirectMusicPerformance),
213 GE(CLSID_DirectMusicScript),
214 GE(CLSID_DirectMusicScriptAutoImpSegment),
215 GE(CLSID_DirectMusicScriptAutoImpPerformance),
216 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
217 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
218 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
219 GE(CLSID_DirectMusicScriptAutoImpSong),
220 GE(CLSID_DirectMusicScriptSourceCodeLoader),
221 GE(CLSID_DirectMusicScriptTrack),
222 GE(CLSID_DirectMusicSection),
223 GE(CLSID_DirectMusicSegment),
224 GE(CLSID_DirectMusicSegmentState),
225 GE(CLSID_DirectMusicSegmentTriggerTrack),
226 GE(CLSID_DirectMusicSegTriggerTrack),
227 GE(CLSID_DirectMusicSeqTrack),
228 GE(CLSID_DirectMusicSignPostTrack),
229 GE(CLSID_DirectMusicSong),
230 GE(CLSID_DirectMusicStyle),
231 GE(CLSID_DirectMusicStyleTrack),
232 GE(CLSID_DirectMusicSynth),
233 GE(CLSID_DirectMusicSynthSink),
234 GE(CLSID_DirectMusicSysExTrack),
235 GE(CLSID_DirectMusicTemplate),
236 GE(CLSID_DirectMusicTempoTrack),
237 GE(CLSID_DirectMusicTimeSigTrack),
238 GE(CLSID_DirectMusicWaveTrack),
239 GE(CLSID_DirectSoundWave),
240 /* IIDs */
241 GE(IID_IDirectMusic),
242 GE(IID_IDirectMusic2),
243 GE(IID_IDirectMusic8),
244 GE(IID_IDirectMusicAudioPath),
245 GE(IID_IDirectMusicBand),
246 GE(IID_IDirectMusicBuffer),
247 GE(IID_IDirectMusicChordMap),
248 GE(IID_IDirectMusicCollection),
249 GE(IID_IDirectMusicComposer),
250 GE(IID_IDirectMusicContainer),
251 GE(IID_IDirectMusicDownload),
252 GE(IID_IDirectMusicDownloadedInstrument),
253 GE(IID_IDirectMusicGetLoader),
254 GE(IID_IDirectMusicGraph),
255 GE(IID_IDirectMusicInstrument),
256 GE(IID_IDirectMusicLoader),
257 GE(IID_IDirectMusicLoader8),
258 GE(IID_IDirectMusicObject),
259 GE(IID_IDirectMusicPatternTrack),
260 GE(IID_IDirectMusicPerformance),
261 GE(IID_IDirectMusicPerformance2),
262 GE(IID_IDirectMusicPerformance8),
263 GE(IID_IDirectMusicPort),
264 GE(IID_IDirectMusicPortDownload),
265 GE(IID_IDirectMusicScript),
266 GE(IID_IDirectMusicSegment),
267 GE(IID_IDirectMusicSegment2),
268 GE(IID_IDirectMusicSegment8),
269 GE(IID_IDirectMusicSegmentState),
270 GE(IID_IDirectMusicSegmentState8),
271 GE(IID_IDirectMusicStyle),
272 GE(IID_IDirectMusicStyle8),
273 GE(IID_IDirectMusicSynth),
274 GE(IID_IDirectMusicSynth8),
275 GE(IID_IDirectMusicSynthSink),
276 GE(IID_IDirectMusicThru),
277 GE(IID_IDirectMusicTool),
278 GE(IID_IDirectMusicTool8),
279 GE(IID_IDirectMusicTrack),
280 GE(IID_IDirectMusicTrack8),
281 GE(IID_IUnknown),
282 GE(IID_IPersistStream),
283 GE(IID_IStream),
284 GE(IID_IClassFactory),
285 /* GUIDs */
286 GE(GUID_DirectMusicAllTypes),
287 GE(GUID_NOTIFICATION_CHORD),
288 GE(GUID_NOTIFICATION_COMMAND),
289 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
290 GE(GUID_NOTIFICATION_PERFORMANCE),
291 GE(GUID_NOTIFICATION_RECOMPOSE),
292 GE(GUID_NOTIFICATION_SEGMENT),
293 GE(GUID_BandParam),
294 GE(GUID_ChordParam),
295 GE(GUID_CommandParam),
296 GE(GUID_CommandParam2),
297 GE(GUID_CommandParamNext),
298 GE(GUID_IDirectMusicBand),
299 GE(GUID_IDirectMusicChordMap),
300 GE(GUID_IDirectMusicStyle),
301 GE(GUID_MuteParam),
302 GE(GUID_Play_Marker),
303 GE(GUID_RhythmParam),
304 GE(GUID_TempoParam),
305 GE(GUID_TimeSignature),
306 GE(GUID_Valid_Start_Time),
307 GE(GUID_Clear_All_Bands),
308 GE(GUID_ConnectToDLSCollection),
309 GE(GUID_Disable_Auto_Download),
310 GE(GUID_DisableTempo),
311 GE(GUID_DisableTimeSig),
312 GE(GUID_Download),
313 GE(GUID_DownloadToAudioPath),
314 GE(GUID_Enable_Auto_Download),
315 GE(GUID_EnableTempo),
316 GE(GUID_EnableTimeSig),
317 GE(GUID_IgnoreBankSelectForGM),
318 GE(GUID_SeedVariations),
319 GE(GUID_StandardMIDIFile),
320 GE(GUID_Unload),
321 GE(GUID_UnloadFromAudioPath),
322 GE(GUID_Variations),
323 GE(GUID_PerfMasterTempo),
324 GE(GUID_PerfMasterVolume),
325 GE(GUID_PerfMasterGrooveLevel),
326 GE(GUID_PerfAutoDownload),
327 GE(GUID_DefaultGMCollection),
328 GE(GUID_Synth_Default),
329 GE(GUID_Buffer_Reverb),
330 GE(GUID_Buffer_EnvReverb),
331 GE(GUID_Buffer_Stereo),
332 GE(GUID_Buffer_3D_Dry),
333 GE(GUID_Buffer_Mono),
334 GE(GUID_DMUS_PROP_GM_Hardware),
335 GE(GUID_DMUS_PROP_GS_Capable),
336 GE(GUID_DMUS_PROP_GS_Hardware),
337 GE(GUID_DMUS_PROP_DLS1),
338 GE(GUID_DMUS_PROP_DLS2),
339 GE(GUID_DMUS_PROP_Effects),
340 GE(GUID_DMUS_PROP_INSTRUMENT2),
341 GE(GUID_DMUS_PROP_LegacyCaps),
342 GE(GUID_DMUS_PROP_MemorySize),
343 GE(GUID_DMUS_PROP_SampleMemorySize),
344 GE(GUID_DMUS_PROP_SamplePlaybackRate),
345 GE(GUID_DMUS_PROP_SetSynthSink),
346 GE(GUID_DMUS_PROP_SinkUsesDSound),
347 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
348 GE(GUID_DMUS_PROP_SynthSink_WAVE),
349 GE(GUID_DMUS_PROP_Volume),
350 GE(GUID_DMUS_PROP_WavesReverb),
351 GE(GUID_DMUS_PROP_WriteLatency),
352 GE(GUID_DMUS_PROP_WritePeriod),
353 GE(GUID_DMUS_PROP_XG_Capable),
354 GE(GUID_DMUS_PROP_XG_Hardware)
357 unsigned int i;
359 if (!id) return "(null)";
361 for (i = 0; i < ARRAY_SIZE(guids); i++) {
362 if (IsEqualGUID(id, guids[i].guid))
363 return guids[i].name;
365 /* if we didn't find it, act like standard debugstr_guid */
366 return debugstr_guid(id);