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 "wine/port.h"
25 #include "dmsynth_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
30 static HINSTANCE instance;
31 LONG DMSYNTH_refCount = 0;
34 const IClassFactoryVtbl *lpVtbl;
37 /******************************************************************
38 * DirectMusicSynth ClassFactory
40 static HRESULT WINAPI SynthCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
41 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
43 if (ppobj == NULL) return E_POINTER;
48 static ULONG WINAPI SynthCF_AddRef(LPCLASSFACTORY iface) {
51 return 2; /* non-heap based object */
54 static ULONG WINAPI SynthCF_Release(LPCLASSFACTORY iface) {
55 DMSYNTH_UnlockModule();
57 return 1; /* non-heap based object */
60 static HRESULT WINAPI SynthCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
61 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
62 return DMUSIC_CreateDirectMusicSynthImpl (riid, ppobj, pOuter);
65 static HRESULT WINAPI SynthCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
66 TRACE("(%d)\n", dolock);
71 DMSYNTH_UnlockModule();
76 static const IClassFactoryVtbl SynthCF_Vtbl = {
77 SynthCF_QueryInterface,
80 SynthCF_CreateInstance,
84 static IClassFactoryImpl Synth_CF = {&SynthCF_Vtbl};
86 /******************************************************************
87 * DirectMusicSynthSink ClassFactory
89 static HRESULT WINAPI SynthSinkCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
90 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
92 if (ppobj == NULL) return E_POINTER;
97 static ULONG WINAPI SynthSinkCF_AddRef(LPCLASSFACTORY iface) {
100 return 2; /* non-heap based object */
103 static ULONG WINAPI SynthSinkCF_Release(LPCLASSFACTORY iface) {
104 DMSYNTH_UnlockModule();
106 return 1; /* non-heap based object */
109 static HRESULT WINAPI SynthSinkCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
110 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
111 return DMUSIC_CreateDirectMusicSynthSinkImpl (riid, ppobj, pOuter);
114 static HRESULT WINAPI SynthSinkCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
115 TRACE("(%d)\n", dolock);
118 DMSYNTH_LockModule();
120 DMSYNTH_UnlockModule();
125 static const IClassFactoryVtbl SynthSinkCF_Vtbl = {
126 SynthSinkCF_QueryInterface,
129 SynthSinkCF_CreateInstance,
130 SynthSinkCF_LockServer
133 static IClassFactoryImpl SynthSink_CF = {&SynthSinkCF_Vtbl};
135 /******************************************************************
140 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
141 if (fdwReason == DLL_PROCESS_ATTACH) {
143 DisableThreadLibraryCalls(hinstDLL);
144 /* FIXME: Initialisation */
145 } else if (fdwReason == DLL_PROCESS_DETACH) {
153 /******************************************************************
154 * DllCanUnloadNow (DMSYNTH.@)
158 HRESULT WINAPI DllCanUnloadNow(void)
160 return DMSYNTH_refCount != 0 ? S_FALSE : S_OK;
164 /******************************************************************
165 * DllGetClassObject (DMSYNTH.@)
169 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
171 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
172 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSynth) && IsEqualIID (riid, &IID_IClassFactory)) {
174 IClassFactory_AddRef((IClassFactory*)*ppv);
176 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSynth) && IsEqualIID (riid, &IID_IClassFactory)) {
177 *ppv = &SynthSink_CF;
178 IClassFactory_AddRef((IClassFactory*)*ppv);
182 WARN("(%s,%s,%p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
183 return CLASS_E_CLASSNOTAVAILABLE;
186 /***********************************************************************
187 * DllRegisterServer (DMSYNTH.@)
189 HRESULT WINAPI DllRegisterServer(void)
191 return __wine_register_resources( instance, NULL );
194 /***********************************************************************
195 * DllUnregisterServer (DMSYNTH.@)
197 HRESULT WINAPI DllUnregisterServer(void)
199 return __wine_unregister_resources( instance, NULL );
202 /******************************************************************
208 /* returns name of given GUID */
209 const char *debugstr_dmguid (const GUID *id) {
210 static const guid_info guids[] = {
212 GE(CLSID_AudioVBScript),
213 GE(CLSID_DirectMusic),
214 GE(CLSID_DirectMusicAudioPath),
215 GE(CLSID_DirectMusicAudioPathConfig),
216 GE(CLSID_DirectMusicAuditionTrack),
217 GE(CLSID_DirectMusicBand),
218 GE(CLSID_DirectMusicBandTrack),
219 GE(CLSID_DirectMusicChordMapTrack),
220 GE(CLSID_DirectMusicChordMap),
221 GE(CLSID_DirectMusicChordTrack),
222 GE(CLSID_DirectMusicCollection),
223 GE(CLSID_DirectMusicCommandTrack),
224 GE(CLSID_DirectMusicComposer),
225 GE(CLSID_DirectMusicContainer),
226 GE(CLSID_DirectMusicGraph),
227 GE(CLSID_DirectMusicLoader),
228 GE(CLSID_DirectMusicLyricsTrack),
229 GE(CLSID_DirectMusicMarkerTrack),
230 GE(CLSID_DirectMusicMelodyFormulationTrack),
231 GE(CLSID_DirectMusicMotifTrack),
232 GE(CLSID_DirectMusicMuteTrack),
233 GE(CLSID_DirectMusicParamControlTrack),
234 GE(CLSID_DirectMusicPatternTrack),
235 GE(CLSID_DirectMusicPerformance),
236 GE(CLSID_DirectMusicScript),
237 GE(CLSID_DirectMusicScriptAutoImpSegment),
238 GE(CLSID_DirectMusicScriptAutoImpPerformance),
239 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
240 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
241 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
242 GE(CLSID_DirectMusicScriptAutoImpSong),
243 GE(CLSID_DirectMusicScriptSourceCodeLoader),
244 GE(CLSID_DirectMusicScriptTrack),
245 GE(CLSID_DirectMusicSection),
246 GE(CLSID_DirectMusicSegment),
247 GE(CLSID_DirectMusicSegmentState),
248 GE(CLSID_DirectMusicSegmentTriggerTrack),
249 GE(CLSID_DirectMusicSegTriggerTrack),
250 GE(CLSID_DirectMusicSeqTrack),
251 GE(CLSID_DirectMusicSignPostTrack),
252 GE(CLSID_DirectMusicSong),
253 GE(CLSID_DirectMusicStyle),
254 GE(CLSID_DirectMusicStyleTrack),
255 GE(CLSID_DirectMusicSynth),
256 GE(CLSID_DirectMusicSynthSink),
257 GE(CLSID_DirectMusicSysExTrack),
258 GE(CLSID_DirectMusicTemplate),
259 GE(CLSID_DirectMusicTempoTrack),
260 GE(CLSID_DirectMusicTimeSigTrack),
261 GE(CLSID_DirectMusicWaveTrack),
262 GE(CLSID_DirectSoundWave),
264 GE(IID_IDirectMusic),
265 GE(IID_IDirectMusic2),
266 GE(IID_IDirectMusic8),
267 GE(IID_IDirectMusicAudioPath),
268 GE(IID_IDirectMusicBand),
269 GE(IID_IDirectMusicBuffer),
270 GE(IID_IDirectMusicChordMap),
271 GE(IID_IDirectMusicCollection),
272 GE(IID_IDirectMusicComposer),
273 GE(IID_IDirectMusicContainer),
274 GE(IID_IDirectMusicDownload),
275 GE(IID_IDirectMusicDownloadedInstrument),
276 GE(IID_IDirectMusicGetLoader),
277 GE(IID_IDirectMusicGraph),
278 GE(IID_IDirectMusicInstrument),
279 GE(IID_IDirectMusicLoader),
280 GE(IID_IDirectMusicLoader8),
281 GE(IID_IDirectMusicObject),
282 GE(IID_IDirectMusicPatternTrack),
283 GE(IID_IDirectMusicPerformance),
284 GE(IID_IDirectMusicPerformance2),
285 GE(IID_IDirectMusicPerformance8),
286 GE(IID_IDirectMusicPort),
287 GE(IID_IDirectMusicPortDownload),
288 GE(IID_IDirectMusicScript),
289 GE(IID_IDirectMusicSegment),
290 GE(IID_IDirectMusicSegment2),
291 GE(IID_IDirectMusicSegment8),
292 GE(IID_IDirectMusicSegmentState),
293 GE(IID_IDirectMusicSegmentState8),
294 GE(IID_IDirectMusicStyle),
295 GE(IID_IDirectMusicStyle8),
296 GE(IID_IDirectMusicSynth),
297 GE(IID_IDirectMusicSynth8),
298 GE(IID_IDirectMusicSynthSink),
299 GE(IID_IDirectMusicThru),
300 GE(IID_IDirectMusicTool),
301 GE(IID_IDirectMusicTool8),
302 GE(IID_IDirectMusicTrack),
303 GE(IID_IDirectMusicTrack8),
305 GE(IID_IPersistStream),
307 GE(IID_IClassFactory),
309 GE(GUID_DirectMusicAllTypes),
310 GE(GUID_NOTIFICATION_CHORD),
311 GE(GUID_NOTIFICATION_COMMAND),
312 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
313 GE(GUID_NOTIFICATION_PERFORMANCE),
314 GE(GUID_NOTIFICATION_RECOMPOSE),
315 GE(GUID_NOTIFICATION_SEGMENT),
318 GE(GUID_CommandParam),
319 GE(GUID_CommandParam2),
320 GE(GUID_CommandParamNext),
321 GE(GUID_IDirectMusicBand),
322 GE(GUID_IDirectMusicChordMap),
323 GE(GUID_IDirectMusicStyle),
325 GE(GUID_Play_Marker),
326 GE(GUID_RhythmParam),
328 GE(GUID_TimeSignature),
329 GE(GUID_Valid_Start_Time),
330 GE(GUID_Clear_All_Bands),
331 GE(GUID_ConnectToDLSCollection),
332 GE(GUID_Disable_Auto_Download),
333 GE(GUID_DisableTempo),
334 GE(GUID_DisableTimeSig),
336 GE(GUID_DownloadToAudioPath),
337 GE(GUID_Enable_Auto_Download),
338 GE(GUID_EnableTempo),
339 GE(GUID_EnableTimeSig),
340 GE(GUID_IgnoreBankSelectForGM),
341 GE(GUID_SeedVariations),
342 GE(GUID_StandardMIDIFile),
344 GE(GUID_UnloadFromAudioPath),
346 GE(GUID_PerfMasterTempo),
347 GE(GUID_PerfMasterVolume),
348 GE(GUID_PerfMasterGrooveLevel),
349 GE(GUID_PerfAutoDownload),
350 GE(GUID_DefaultGMCollection),
351 GE(GUID_Synth_Default),
352 GE(GUID_Buffer_Reverb),
353 GE(GUID_Buffer_EnvReverb),
354 GE(GUID_Buffer_Stereo),
355 GE(GUID_Buffer_3D_Dry),
356 GE(GUID_Buffer_Mono),
357 GE(GUID_DMUS_PROP_GM_Hardware),
358 GE(GUID_DMUS_PROP_GS_Capable),
359 GE(GUID_DMUS_PROP_GS_Hardware),
360 GE(GUID_DMUS_PROP_DLS1),
361 GE(GUID_DMUS_PROP_DLS2),
362 GE(GUID_DMUS_PROP_Effects),
363 GE(GUID_DMUS_PROP_INSTRUMENT2),
364 GE(GUID_DMUS_PROP_LegacyCaps),
365 GE(GUID_DMUS_PROP_MemorySize),
366 GE(GUID_DMUS_PROP_SampleMemorySize),
367 GE(GUID_DMUS_PROP_SamplePlaybackRate),
368 GE(GUID_DMUS_PROP_SetSynthSink),
369 GE(GUID_DMUS_PROP_SinkUsesDSound),
370 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
371 GE(GUID_DMUS_PROP_SynthSink_WAVE),
372 GE(GUID_DMUS_PROP_Volume),
373 GE(GUID_DMUS_PROP_WavesReverb),
374 GE(GUID_DMUS_PROP_WriteLatency),
375 GE(GUID_DMUS_PROP_WritePeriod),
376 GE(GUID_DMUS_PROP_XG_Capable),
377 GE(GUID_DMUS_PROP_XG_Hardware)
382 if (!id) return "(null)";
384 for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
385 if (IsEqualGUID(id, guids[i].guid))
386 return guids[i].name;
388 /* if we didn't find it, act like standard debugstr_guid */
389 return debugstr_guid(id);