dbghelp: Use RtlGetVersion() for system version detection instead.
[wine.git] / dlls / dmsynth / dmsynth_main.c
blob014eb0eb6f175fd0b5526c4370389594dee662ea
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 LONG DMSYNTH_refCount = 0;
30 typedef struct {
31 IClassFactory IClassFactory_iface;
32 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ppv);
33 } IClassFactoryImpl;
35 /******************************************************************
36 * IClassFactory implementation
38 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
40 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
43 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
45 if (ppv == NULL)
46 return E_POINTER;
48 if (IsEqualGUID(&IID_IUnknown, riid))
49 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
50 else if (IsEqualGUID(&IID_IClassFactory, riid))
51 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
52 else {
53 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
54 *ppv = NULL;
55 return E_NOINTERFACE;
58 *ppv = iface;
59 IUnknown_AddRef((IUnknown*)*ppv);
60 return S_OK;
63 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
65 DMSYNTH_LockModule();
67 return 2; /* non-heap based object */
70 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
72 DMSYNTH_UnlockModule();
74 return 1; /* non-heap based object */
77 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
78 REFIID riid, void **ppv)
80 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
82 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
84 if (pUnkOuter)
85 return CLASS_E_NOAGGREGATION;
87 return This->fnCreateInstance(riid, ppv);
90 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
92 TRACE("(%d)\n", dolock);
94 if (dolock)
95 DMSYNTH_LockModule();
96 else
97 DMSYNTH_UnlockModule();
99 return S_OK;
102 static const IClassFactoryVtbl classfactory_vtbl = {
103 ClassFactory_QueryInterface,
104 ClassFactory_AddRef,
105 ClassFactory_Release,
106 ClassFactory_CreateInstance,
107 ClassFactory_LockServer
110 static IClassFactoryImpl Synth_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicSynthImpl};
111 static IClassFactoryImpl SynthSink_CF = {{&classfactory_vtbl},
112 DMUSIC_CreateDirectMusicSynthSinkImpl};
114 /******************************************************************
115 * DllCanUnloadNow (DMSYNTH.@)
119 HRESULT WINAPI DllCanUnloadNow(void)
121 return DMSYNTH_refCount != 0 ? S_FALSE : S_OK;
125 /******************************************************************
126 * DllGetClassObject (DMSYNTH.@)
130 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
132 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
134 if (IsEqualCLSID(rclsid, &CLSID_DirectMusicSynth) && IsEqualIID(riid, &IID_IClassFactory)) {
135 *ppv = &Synth_CF;
136 IClassFactory_AddRef((IClassFactory*)*ppv);
137 return S_OK;
138 } else if (IsEqualCLSID(rclsid, &CLSID_DirectMusicSynthSink) && IsEqualIID(riid, &IID_IClassFactory)) {
139 *ppv = &SynthSink_CF;
140 IClassFactory_AddRef((IClassFactory*)*ppv);
141 return S_OK;
144 WARN("(%s,%s,%p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
145 return CLASS_E_CLASSNOTAVAILABLE;
148 /******************************************************************
149 * Helper functions
154 /* returns name of given GUID */
155 const char *debugstr_dmguid (const GUID *id) {
156 static const guid_info guids[] = {
157 /* CLSIDs */
158 GE(CLSID_AudioVBScript),
159 GE(CLSID_DirectMusic),
160 GE(CLSID_DirectMusicAudioPathConfig),
161 GE(CLSID_DirectMusicAuditionTrack),
162 GE(CLSID_DirectMusicBand),
163 GE(CLSID_DirectMusicBandTrack),
164 GE(CLSID_DirectMusicChordMapTrack),
165 GE(CLSID_DirectMusicChordMap),
166 GE(CLSID_DirectMusicChordTrack),
167 GE(CLSID_DirectMusicCollection),
168 GE(CLSID_DirectMusicCommandTrack),
169 GE(CLSID_DirectMusicComposer),
170 GE(CLSID_DirectMusicContainer),
171 GE(CLSID_DirectMusicGraph),
172 GE(CLSID_DirectMusicLoader),
173 GE(CLSID_DirectMusicLyricsTrack),
174 GE(CLSID_DirectMusicMarkerTrack),
175 GE(CLSID_DirectMusicMelodyFormulationTrack),
176 GE(CLSID_DirectMusicMotifTrack),
177 GE(CLSID_DirectMusicMuteTrack),
178 GE(CLSID_DirectMusicParamControlTrack),
179 GE(CLSID_DirectMusicPatternTrack),
180 GE(CLSID_DirectMusicPerformance),
181 GE(CLSID_DirectMusicScript),
182 GE(CLSID_DirectMusicScriptAutoImpSegment),
183 GE(CLSID_DirectMusicScriptAutoImpPerformance),
184 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
185 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
186 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
187 GE(CLSID_DirectMusicScriptAutoImpSong),
188 GE(CLSID_DirectMusicScriptSourceCodeLoader),
189 GE(CLSID_DirectMusicScriptTrack),
190 GE(CLSID_DirectMusicSection),
191 GE(CLSID_DirectMusicSegment),
192 GE(CLSID_DirectMusicSegmentState),
193 GE(CLSID_DirectMusicSegmentTriggerTrack),
194 GE(CLSID_DirectMusicSegTriggerTrack),
195 GE(CLSID_DirectMusicSeqTrack),
196 GE(CLSID_DirectMusicSignPostTrack),
197 GE(CLSID_DirectMusicSong),
198 GE(CLSID_DirectMusicStyle),
199 GE(CLSID_DirectMusicStyleTrack),
200 GE(CLSID_DirectMusicSynth),
201 GE(CLSID_DirectMusicSynthSink),
202 GE(CLSID_DirectMusicSysExTrack),
203 GE(CLSID_DirectMusicTemplate),
204 GE(CLSID_DirectMusicTempoTrack),
205 GE(CLSID_DirectMusicTimeSigTrack),
206 GE(CLSID_DirectMusicWaveTrack),
207 GE(CLSID_DirectSoundWave),
208 /* IIDs */
209 GE(IID_IDirectMusic),
210 GE(IID_IDirectMusic2),
211 GE(IID_IDirectMusic8),
212 GE(IID_IDirectMusicAudioPath),
213 GE(IID_IDirectMusicBand),
214 GE(IID_IDirectMusicBuffer),
215 GE(IID_IDirectMusicChordMap),
216 GE(IID_IDirectMusicCollection),
217 GE(IID_IDirectMusicComposer),
218 GE(IID_IDirectMusicContainer),
219 GE(IID_IDirectMusicDownload),
220 GE(IID_IDirectMusicDownloadedInstrument),
221 GE(IID_IDirectMusicGetLoader),
222 GE(IID_IDirectMusicGraph),
223 GE(IID_IDirectMusicInstrument),
224 GE(IID_IDirectMusicLoader),
225 GE(IID_IDirectMusicLoader8),
226 GE(IID_IDirectMusicObject),
227 GE(IID_IDirectMusicPatternTrack),
228 GE(IID_IDirectMusicPerformance),
229 GE(IID_IDirectMusicPerformance2),
230 GE(IID_IDirectMusicPerformance8),
231 GE(IID_IDirectMusicPort),
232 GE(IID_IDirectMusicPortDownload),
233 GE(IID_IDirectMusicScript),
234 GE(IID_IDirectMusicSegment),
235 GE(IID_IDirectMusicSegment2),
236 GE(IID_IDirectMusicSegment8),
237 GE(IID_IDirectMusicSegmentState),
238 GE(IID_IDirectMusicSegmentState8),
239 GE(IID_IDirectMusicStyle),
240 GE(IID_IDirectMusicStyle8),
241 GE(IID_IDirectMusicSynth),
242 GE(IID_IDirectMusicSynth8),
243 GE(IID_IDirectMusicSynthSink),
244 GE(IID_IDirectMusicThru),
245 GE(IID_IDirectMusicTool),
246 GE(IID_IDirectMusicTool8),
247 GE(IID_IDirectMusicTrack),
248 GE(IID_IDirectMusicTrack8),
249 GE(IID_IUnknown),
250 GE(IID_IPersistStream),
251 GE(IID_IStream),
252 GE(IID_IClassFactory),
253 /* GUIDs */
254 GE(GUID_DirectMusicAllTypes),
255 GE(GUID_NOTIFICATION_CHORD),
256 GE(GUID_NOTIFICATION_COMMAND),
257 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
258 GE(GUID_NOTIFICATION_PERFORMANCE),
259 GE(GUID_NOTIFICATION_RECOMPOSE),
260 GE(GUID_NOTIFICATION_SEGMENT),
261 GE(GUID_BandParam),
262 GE(GUID_ChordParam),
263 GE(GUID_CommandParam),
264 GE(GUID_CommandParam2),
265 GE(GUID_CommandParamNext),
266 GE(GUID_IDirectMusicBand),
267 GE(GUID_IDirectMusicChordMap),
268 GE(GUID_IDirectMusicStyle),
269 GE(GUID_MuteParam),
270 GE(GUID_Play_Marker),
271 GE(GUID_RhythmParam),
272 GE(GUID_TempoParam),
273 GE(GUID_TimeSignature),
274 GE(GUID_Valid_Start_Time),
275 GE(GUID_Clear_All_Bands),
276 GE(GUID_ConnectToDLSCollection),
277 GE(GUID_Disable_Auto_Download),
278 GE(GUID_DisableTempo),
279 GE(GUID_DisableTimeSig),
280 GE(GUID_Download),
281 GE(GUID_DownloadToAudioPath),
282 GE(GUID_Enable_Auto_Download),
283 GE(GUID_EnableTempo),
284 GE(GUID_EnableTimeSig),
285 GE(GUID_IgnoreBankSelectForGM),
286 GE(GUID_SeedVariations),
287 GE(GUID_StandardMIDIFile),
288 GE(GUID_Unload),
289 GE(GUID_UnloadFromAudioPath),
290 GE(GUID_Variations),
291 GE(GUID_PerfMasterTempo),
292 GE(GUID_PerfMasterVolume),
293 GE(GUID_PerfMasterGrooveLevel),
294 GE(GUID_PerfAutoDownload),
295 GE(GUID_DefaultGMCollection),
296 GE(GUID_Synth_Default),
297 GE(GUID_Buffer_Reverb),
298 GE(GUID_Buffer_EnvReverb),
299 GE(GUID_Buffer_Stereo),
300 GE(GUID_Buffer_3D_Dry),
301 GE(GUID_Buffer_Mono),
302 GE(GUID_DMUS_PROP_GM_Hardware),
303 GE(GUID_DMUS_PROP_GS_Capable),
304 GE(GUID_DMUS_PROP_GS_Hardware),
305 GE(GUID_DMUS_PROP_DLS1),
306 GE(GUID_DMUS_PROP_DLS2),
307 GE(GUID_DMUS_PROP_Effects),
308 GE(GUID_DMUS_PROP_INSTRUMENT2),
309 GE(GUID_DMUS_PROP_LegacyCaps),
310 GE(GUID_DMUS_PROP_MemorySize),
311 GE(GUID_DMUS_PROP_SampleMemorySize),
312 GE(GUID_DMUS_PROP_SamplePlaybackRate),
313 GE(GUID_DMUS_PROP_SetSynthSink),
314 GE(GUID_DMUS_PROP_SinkUsesDSound),
315 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
316 GE(GUID_DMUS_PROP_SynthSink_WAVE),
317 GE(GUID_DMUS_PROP_Volume),
318 GE(GUID_DMUS_PROP_WavesReverb),
319 GE(GUID_DMUS_PROP_WriteLatency),
320 GE(GUID_DMUS_PROP_WritePeriod),
321 GE(GUID_DMUS_PROP_XG_Capable),
322 GE(GUID_DMUS_PROP_XG_Hardware)
325 unsigned int i;
327 if (!id) return "(null)";
329 for (i = 0; i < ARRAY_SIZE(guids); i++) {
330 if (IsEqualGUID(id, guids[i].guid))
331 return guids[i].name;
333 /* if we didn't find it, act like standard debugstr_guid */
334 return debugstr_guid(id);