Get rid of the no longer used ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
[wine] / dlls / dmcompos / dmcompos_main.c
1 /* DirectMusicComposer Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
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
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "dmcompos_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
23
24 typedef struct {
25     /* IUnknown fields */
26     IClassFactoryVtbl          *lpVtbl;
27     DWORD                       ref;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicChordMap ClassFactory
32  */
33 static HRESULT WINAPI ChordMapCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
34         ICOM_THIS(IClassFactoryImpl,iface);
35         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
36         return E_NOINTERFACE;
37 }
38
39 static ULONG WINAPI ChordMapCF_AddRef(LPCLASSFACTORY iface) {
40         ICOM_THIS(IClassFactoryImpl,iface);
41         return ++(This->ref);
42 }
43
44 static ULONG WINAPI ChordMapCF_Release(LPCLASSFACTORY iface) {
45         ICOM_THIS(IClassFactoryImpl,iface);
46         /* static class, won't be  freed */
47         return --(This->ref);
48 }
49
50 static HRESULT WINAPI ChordMapCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
51         ICOM_THIS(IClassFactoryImpl,iface);
52         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
53         return DMUSIC_CreateDirectMusicChordMapImpl (riid, ppobj, pOuter);
54 }
55
56 static HRESULT WINAPI ChordMapCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
57         ICOM_THIS(IClassFactoryImpl,iface);
58         FIXME("(%p, %d): stub\n", This, dolock);
59         return S_OK;
60 }
61
62 static IClassFactoryVtbl ChordMapCF_Vtbl = {
63         ChordMapCF_QueryInterface,
64         ChordMapCF_AddRef,
65         ChordMapCF_Release,
66         ChordMapCF_CreateInstance,
67         ChordMapCF_LockServer
68 };
69
70 static IClassFactoryImpl ChordMap_CF = {&ChordMapCF_Vtbl, 1 };
71
72 /******************************************************************
73  *              DirectMusicComposer ClassFactory
74  */
75 static HRESULT WINAPI ComposerCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
76         ICOM_THIS(IClassFactoryImpl,iface);
77         FIXME("(%p, %s, %p): stub\n",This,debugstr_dmguid(riid),ppobj);
78         return E_NOINTERFACE;
79 }
80
81 static ULONG WINAPI ComposerCF_AddRef(LPCLASSFACTORY iface) {
82         ICOM_THIS(IClassFactoryImpl,iface);
83         return ++(This->ref);
84 }
85
86 static ULONG WINAPI ComposerCF_Release(LPCLASSFACTORY iface) {
87         ICOM_THIS(IClassFactoryImpl,iface);
88         /* static class, won't be  freed */
89         return --(This->ref);
90 }
91
92 static HRESULT WINAPI ComposerCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
93         ICOM_THIS(IClassFactoryImpl,iface);
94         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
95         return DMUSIC_CreateDirectMusicComposerImpl (riid, ppobj, pOuter);
96 }
97
98 static HRESULT WINAPI ComposerCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
99         ICOM_THIS(IClassFactoryImpl,iface);
100         FIXME("(%p, %d): stub\n", This, dolock);
101         return S_OK;
102 }
103
104 static IClassFactoryVtbl ComposerCF_Vtbl = {
105         ComposerCF_QueryInterface,
106         ComposerCF_AddRef,
107         ComposerCF_Release,
108         ComposerCF_CreateInstance,
109         ComposerCF_LockServer
110 };
111
112 static IClassFactoryImpl Composer_CF = {&ComposerCF_Vtbl, 1 };
113
114 /******************************************************************
115  *              DirectMusicChordMapTrack ClassFactory
116  */
117 static HRESULT WINAPI ChordMapTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
118         ICOM_THIS(IClassFactoryImpl,iface);
119         FIXME("(%p, %s, %p): stub\n",This,debugstr_dmguid(riid),ppobj);
120         return E_NOINTERFACE;
121 }
122
123 static ULONG WINAPI ChordMapTrackCF_AddRef(LPCLASSFACTORY iface) {
124         ICOM_THIS(IClassFactoryImpl,iface);
125         return ++(This->ref);
126 }
127
128 static ULONG WINAPI ChordMapTrackCF_Release(LPCLASSFACTORY iface) {
129         ICOM_THIS(IClassFactoryImpl,iface);
130         /* static class, won't be  freed */
131         return --(This->ref);
132 }
133
134 static HRESULT WINAPI ChordMapTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
135         ICOM_THIS(IClassFactoryImpl,iface);
136         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
137         return DMUSIC_CreateDirectMusicChordMapTrack (riid, ppobj, pOuter);
138 }
139
140 static HRESULT WINAPI ChordMapTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
141         ICOM_THIS(IClassFactoryImpl,iface);
142         FIXME("(%p, %d): stub\n", This, dolock);
143         return S_OK;
144 }
145
146 static IClassFactoryVtbl ChordMapTrackCF_Vtbl = {
147         ChordMapTrackCF_QueryInterface,
148         ChordMapTrackCF_AddRef,
149         ChordMapTrackCF_Release,
150         ChordMapTrackCF_CreateInstance,
151         ChordMapTrackCF_LockServer
152 };
153
154 static IClassFactoryImpl ChordMapTrack_CF = {&ChordMapTrackCF_Vtbl, 1 };
155
156 /******************************************************************
157  *              DirectMusicTemplate ClassFactory
158  */
159 static HRESULT WINAPI TemplateCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
160         ICOM_THIS(IClassFactoryImpl,iface);
161         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
162         return E_NOINTERFACE;
163 }
164
165 static ULONG WINAPI TemplateCF_AddRef(LPCLASSFACTORY iface) {
166         ICOM_THIS(IClassFactoryImpl,iface);
167         return ++(This->ref);
168 }
169
170 static ULONG WINAPI TemplateCF_Release(LPCLASSFACTORY iface) {
171         ICOM_THIS(IClassFactoryImpl,iface);
172         /* static class, won't be  freed */
173         return --(This->ref);
174 }
175
176 static HRESULT WINAPI TemplateCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
177         ICOM_THIS(IClassFactoryImpl,iface);
178         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
179         /* nothing yet */
180         WARN("(%p, %s,%p): not found\n", This, debugstr_dmguid(riid), ppobj);
181         return E_NOINTERFACE;
182 }
183
184 static HRESULT WINAPI TemplateCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
185         ICOM_THIS(IClassFactoryImpl,iface);
186         FIXME("(%p, %d): stub\n", This, dolock);
187         return S_OK;
188 }
189
190 static IClassFactoryVtbl TemplateCF_Vtbl = {
191         TemplateCF_QueryInterface,
192         TemplateCF_AddRef,
193         TemplateCF_Release,
194         TemplateCF_CreateInstance,
195         TemplateCF_LockServer
196 };
197
198 static IClassFactoryImpl Template_CF = {&TemplateCF_Vtbl, 1 };
199
200 /******************************************************************
201  *              DirectMusicSignPostTrack ClassFactory
202  */
203 static HRESULT WINAPI SignPostTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
204         ICOM_THIS(IClassFactoryImpl,iface);
205         FIXME("(%p, %s, %p): stub\n",This,debugstr_dmguid(riid),ppobj);
206         return E_NOINTERFACE;
207 }
208
209 static ULONG WINAPI SignPostTrackCF_AddRef(LPCLASSFACTORY iface) {
210         ICOM_THIS(IClassFactoryImpl,iface);
211         return ++(This->ref);
212 }
213
214 static ULONG WINAPI SignPostTrackCF_Release(LPCLASSFACTORY iface) {
215         ICOM_THIS(IClassFactoryImpl,iface);
216         /* static class, won't be  freed */
217         return --(This->ref);
218 }
219
220 static HRESULT WINAPI SignPostTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
221         ICOM_THIS(IClassFactoryImpl,iface);
222         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
223         return DMUSIC_CreateDirectMusicSignPostTrack (riid, ppobj, pOuter);
224 }
225
226 static HRESULT WINAPI SignPostTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
227         ICOM_THIS(IClassFactoryImpl,iface);
228         FIXME("(%p, %d): stub\n", This, dolock);
229         return S_OK;
230 }
231
232 static IClassFactoryVtbl SignPostTrackCF_Vtbl = {
233         SignPostTrackCF_QueryInterface,
234         SignPostTrackCF_AddRef,
235         SignPostTrackCF_Release,
236         SignPostTrackCF_CreateInstance,
237         SignPostTrackCF_LockServer
238 };
239
240 static IClassFactoryImpl SignPostTrack_CF = {&SignPostTrackCF_Vtbl, 1 };
241
242 /******************************************************************
243  *              DllMain
244  *
245  *
246  */
247 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
248         if (fdwReason == DLL_PROCESS_ATTACH)    {
249             DisableThreadLibraryCalls(hinstDLL);
250                 /* FIXME: Initialisation */
251         }
252         else if (fdwReason == DLL_PROCESS_DETACH)       {
253                 /* FIXME: Cleanup */
254         }
255
256         return TRUE;
257 }
258
259
260 /******************************************************************
261  *              DllCanUnloadNow (DMCOMPOS.1)
262  *
263  *
264  */
265 HRESULT WINAPI DMCOMPOS_DllCanUnloadNow(void) {
266     FIXME("(void): stub\n");
267     return S_FALSE;
268 }
269
270
271 /******************************************************************
272  *              DllGetClassObject (DMCOMPOS.2)
273  *
274  *
275  */
276 HRESULT WINAPI DMCOMPOS_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
277     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
278     if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMap) && IsEqualIID (riid, &IID_IClassFactory)) {
279                 *ppv = (LPVOID) &ChordMap_CF;
280                 IClassFactory_AddRef((IClassFactory*)*ppv);
281                 return S_OK;
282         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicComposer) && IsEqualIID (riid, &IID_IClassFactory)) { 
283                 *ppv = (LPVOID) &Composer_CF;
284                 IClassFactory_AddRef((IClassFactory*)*ppv);             
285                 return S_OK;
286         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordMapTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
287                 *ppv = (LPVOID) &ChordMapTrack_CF;
288                 IClassFactory_AddRef((IClassFactory*)*ppv);             
289                 return S_OK;
290         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTemplate) && IsEqualIID (riid, &IID_IClassFactory)) {
291                 *ppv = (LPVOID) &Template_CF;
292                 IClassFactory_AddRef((IClassFactory*)*ppv);             
293                 return S_OK;
294         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSignPostTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
295                 *ppv = (LPVOID) &SignPostTrack_CF;
296                 IClassFactory_AddRef((IClassFactory*)*ppv);             
297                 return S_OK;
298         }
299
300     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
301     return CLASS_E_CLASSNOTAVAILABLE;
302 }
303
304
305 /******************************************************************
306  *              Helper functions
307  *
308  *
309  */
310 /* check whether the given DWORD is even (return 0) or odd (return 1) */
311 int even_or_odd (DWORD number) {
312         return (number & 0x1); /* basically, check if bit 0 is set ;) */
313 }
314
315 /* FOURCC to string conversion for debug messages */
316 const char *debugstr_fourcc (DWORD fourcc) {
317     if (!fourcc) return "'null'";
318     return wine_dbg_sprintf ("\'%c%c%c%c\'",
319                 (char)(fourcc), (char)(fourcc >> 8),
320         (char)(fourcc >> 16), (char)(fourcc >> 24));
321 }
322
323 /* DMUS_VERSION struct to string conversion for debug messages */
324 const char *debugstr_dmversion (LPDMUS_VERSION version) {
325         if (!version) return "'null'";
326         return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
327                 (int)((version->dwVersionMS && 0xFFFF0000) >> 8), (int)(version->dwVersionMS && 0x0000FFFF), 
328                 (int)((version->dwVersionLS && 0xFFFF0000) >> 8), (int)(version->dwVersionLS && 0x0000FFFF));
329 }
330
331 /* returns name of given GUID */
332 const char *debugstr_dmguid (const GUID *id) {
333         static const guid_info guids[] = {
334                 /* CLSIDs */
335                 GE(CLSID_AudioVBScript),
336                 GE(CLSID_DirectMusic),
337                 GE(CLSID_DirectMusicAudioPath),
338                 GE(CLSID_DirectMusicAudioPathConfig),
339                 GE(CLSID_DirectMusicAuditionTrack),
340                 GE(CLSID_DirectMusicBand),
341                 GE(CLSID_DirectMusicBandTrack),
342                 GE(CLSID_DirectMusicChordMapTrack),
343                 GE(CLSID_DirectMusicChordMap),
344                 GE(CLSID_DirectMusicChordTrack),
345                 GE(CLSID_DirectMusicCollection),
346                 GE(CLSID_DirectMusicCommandTrack),
347                 GE(CLSID_DirectMusicComposer),
348                 GE(CLSID_DirectMusicContainer),
349                 GE(CLSID_DirectMusicGraph),
350                 GE(CLSID_DirectMusicLoader),
351                 GE(CLSID_DirectMusicLyricsTrack),
352                 GE(CLSID_DirectMusicMarkerTrack),
353                 GE(CLSID_DirectMusicMelodyFormulationTrack),
354                 GE(CLSID_DirectMusicMotifTrack),
355                 GE(CLSID_DirectMusicMuteTrack),
356                 GE(CLSID_DirectMusicParamControlTrack),
357                 GE(CLSID_DirectMusicPatternTrack),
358                 GE(CLSID_DirectMusicPerformance),
359                 GE(CLSID_DirectMusicScript),
360                 GE(CLSID_DirectMusicScriptAutoImpSegment),
361                 GE(CLSID_DirectMusicScriptAutoImpPerformance),
362                 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
363                 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
364                 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
365                 GE(CLSID_DirectMusicScriptAutoImpSong),
366                 GE(CLSID_DirectMusicScriptSourceCodeLoader),
367                 GE(CLSID_DirectMusicScriptTrack),
368                 GE(CLSID_DirectMusicSection),
369                 GE(CLSID_DirectMusicSegment),
370                 GE(CLSID_DirectMusicSegmentState),
371                 GE(CLSID_DirectMusicSegmentTriggerTrack),
372                 GE(CLSID_DirectMusicSegTriggerTrack),
373                 GE(CLSID_DirectMusicSeqTrack),
374                 GE(CLSID_DirectMusicSignPostTrack),
375                 GE(CLSID_DirectMusicSong),
376                 GE(CLSID_DirectMusicStyle),
377                 GE(CLSID_DirectMusicStyleTrack),
378                 GE(CLSID_DirectMusicSynth),
379                 GE(CLSID_DirectMusicSynthSink),
380                 GE(CLSID_DirectMusicSysExTrack),
381                 GE(CLSID_DirectMusicTemplate),
382                 GE(CLSID_DirectMusicTempoTrack),
383                 GE(CLSID_DirectMusicTimeSigTrack),
384                 GE(CLSID_DirectMusicWaveTrack),
385                 GE(CLSID_DirectSoundWave),
386                 /* IIDs */
387                 GE(IID_IDirectMusic),
388                 GE(IID_IDirectMusic2),
389                 GE(IID_IDirectMusic8),
390                 GE(IID_IDirectMusicAudioPath),
391                 GE(IID_IDirectMusicBand),
392                 GE(IID_IDirectMusicBuffer),
393                 GE(IID_IDirectMusicChordMap),
394                 GE(IID_IDirectMusicCollection),
395                 GE(IID_IDirectMusicComposer),
396                 GE(IID_IDirectMusicContainer),
397                 GE(IID_IDirectMusicDownload),
398                 GE(IID_IDirectMusicDownloadedInstrument),
399                 GE(IID_IDirectMusicGetLoader),
400                 GE(IID_IDirectMusicGraph),
401                 GE(IID_IDirectMusicInstrument),
402                 GE(IID_IDirectMusicLoader),
403                 GE(IID_IDirectMusicLoader8),
404                 GE(IID_IDirectMusicObject),
405                 GE(IID_IDirectMusicPatternTrack),
406                 GE(IID_IDirectMusicPerformance),
407                 GE(IID_IDirectMusicPerformance2),
408                 GE(IID_IDirectMusicPerformance8),
409                 GE(IID_IDirectMusicPort),
410                 GE(IID_IDirectMusicPortDownload),
411                 GE(IID_IDirectMusicScript),
412                 GE(IID_IDirectMusicSegment),
413                 GE(IID_IDirectMusicSegment2),
414                 GE(IID_IDirectMusicSegment8),
415                 GE(IID_IDirectMusicSegmentState),
416                 GE(IID_IDirectMusicSegmentState8),
417                 GE(IID_IDirectMusicStyle),
418                 GE(IID_IDirectMusicStyle8),
419                 GE(IID_IDirectMusicSynth),
420                 GE(IID_IDirectMusicSynth8),
421                 GE(IID_IDirectMusicSynthSink),
422                 GE(IID_IDirectMusicThru),
423                 GE(IID_IDirectMusicTool),
424                 GE(IID_IDirectMusicTool8),
425                 GE(IID_IDirectMusicTrack),
426                 GE(IID_IDirectMusicTrack8),
427                 GE(IID_IUnknown),
428                 GE(IID_IPersistStream),
429                 GE(IID_IStream),
430                 GE(IID_IClassFactory),
431                 /* GUIDs */
432                 GE(GUID_DirectMusicAllTypes),
433                 GE(GUID_NOTIFICATION_CHORD),
434                 GE(GUID_NOTIFICATION_COMMAND),
435                 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
436                 GE(GUID_NOTIFICATION_PERFORMANCE),
437                 GE(GUID_NOTIFICATION_RECOMPOSE),
438                 GE(GUID_NOTIFICATION_SEGMENT),
439                 GE(GUID_BandParam),
440                 GE(GUID_ChordParam),
441                 GE(GUID_CommandParam),
442                 GE(GUID_CommandParam2),
443                 GE(GUID_CommandParamNext),
444                 GE(GUID_IDirectMusicBand),
445                 GE(GUID_IDirectMusicChordMap),
446                 GE(GUID_IDirectMusicStyle),
447                 GE(GUID_MuteParam),
448                 GE(GUID_Play_Marker),
449                 GE(GUID_RhythmParam),
450                 GE(GUID_TempoParam),
451                 GE(GUID_TimeSignature),
452                 GE(GUID_Valid_Start_Time),
453                 GE(GUID_Clear_All_Bands),
454                 GE(GUID_ConnectToDLSCollection),
455                 GE(GUID_Disable_Auto_Download),
456                 GE(GUID_DisableTempo),
457                 GE(GUID_DisableTimeSig),
458                 GE(GUID_Download),
459                 GE(GUID_DownloadToAudioPath),
460                 GE(GUID_Enable_Auto_Download),
461                 GE(GUID_EnableTempo),
462                 GE(GUID_EnableTimeSig),
463                 GE(GUID_IgnoreBankSelectForGM),
464                 GE(GUID_SeedVariations),
465                 GE(GUID_StandardMIDIFile),
466                 GE(GUID_Unload),
467                 GE(GUID_UnloadFromAudioPath),
468                 GE(GUID_Variations),
469                 GE(GUID_PerfMasterTempo),
470                 GE(GUID_PerfMasterVolume),
471                 GE(GUID_PerfMasterGrooveLevel),
472                 GE(GUID_PerfAutoDownload),
473                 GE(GUID_DefaultGMCollection),
474                 GE(GUID_Synth_Default),
475                 GE(GUID_Buffer_Reverb),
476                 GE(GUID_Buffer_EnvReverb),
477                 GE(GUID_Buffer_Stereo),
478                 GE(GUID_Buffer_3D_Dry),
479                 GE(GUID_Buffer_Mono),
480                 GE(GUID_DMUS_PROP_GM_Hardware),
481                 GE(GUID_DMUS_PROP_GS_Capable),
482                 GE(GUID_DMUS_PROP_GS_Hardware),
483                 GE(GUID_DMUS_PROP_DLS1),
484                 GE(GUID_DMUS_PROP_DLS2),
485                 GE(GUID_DMUS_PROP_Effects),
486                 GE(GUID_DMUS_PROP_INSTRUMENT2),
487                 GE(GUID_DMUS_PROP_LegacyCaps),
488                 GE(GUID_DMUS_PROP_MemorySize),
489                 GE(GUID_DMUS_PROP_SampleMemorySize),
490                 GE(GUID_DMUS_PROP_SamplePlaybackRate),
491                 GE(GUID_DMUS_PROP_SetSynthSink),
492                 GE(GUID_DMUS_PROP_SinkUsesDSound),
493                 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
494                 GE(GUID_DMUS_PROP_SynthSink_WAVE),
495                 GE(GUID_DMUS_PROP_Volume),
496                 GE(GUID_DMUS_PROP_WavesReverb),
497                 GE(GUID_DMUS_PROP_WriteLatency),
498                 GE(GUID_DMUS_PROP_WritePeriod),
499                 GE(GUID_DMUS_PROP_XG_Capable),
500                 GE(GUID_DMUS_PROP_XG_Hardware)
501         };
502
503         unsigned int i;
504
505         if (!id) return "(null)";
506
507         for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
508                 if (IsEqualGUID(id, &guids[i].guid))
509                         return guids[i].name;
510         }
511         /* if we didn't find it, act like standard debugstr_guid */     
512         return debugstr_guid(id);
513 }       
514
515 /* returns name of given error code */
516 const char *debugstr_dmreturn (DWORD code) {
517         static const flag_info codes[] = {
518                 FE(S_OK),
519                 FE(S_FALSE),
520                 FE(DMUS_S_PARTIALLOAD),
521                 FE(DMUS_S_PARTIALDOWNLOAD),
522                 FE(DMUS_S_REQUEUE),
523                 FE(DMUS_S_FREE),
524                 FE(DMUS_S_END),
525                 FE(DMUS_S_STRING_TRUNCATED),
526                 FE(DMUS_S_LAST_TOOL),
527                 FE(DMUS_S_OVER_CHORD),
528                 FE(DMUS_S_UP_OCTAVE),
529                 FE(DMUS_S_DOWN_OCTAVE),
530                 FE(DMUS_S_NOBUFFERCONTROL),
531                 FE(DMUS_S_GARBAGE_COLLECTED),
532                 FE(DMUS_E_DRIVER_FAILED),
533                 FE(DMUS_E_PORTS_OPEN),
534                 FE(DMUS_E_DEVICE_IN_USE),
535                 FE(DMUS_E_INSUFFICIENTBUFFER),
536                 FE(DMUS_E_BUFFERNOTSET),
537                 FE(DMUS_E_BUFFERNOTAVAILABLE),
538                 FE(DMUS_E_NOTADLSCOL),
539                 FE(DMUS_E_INVALIDOFFSET),
540                 FE(DMUS_E_ALREADY_LOADED),
541                 FE(DMUS_E_INVALIDPOS),
542                 FE(DMUS_E_INVALIDPATCH),
543                 FE(DMUS_E_CANNOTSEEK),
544                 FE(DMUS_E_CANNOTWRITE),
545                 FE(DMUS_E_CHUNKNOTFOUND),
546                 FE(DMUS_E_INVALID_DOWNLOADID),
547                 FE(DMUS_E_NOT_DOWNLOADED_TO_PORT),
548                 FE(DMUS_E_ALREADY_DOWNLOADED),
549                 FE(DMUS_E_UNKNOWN_PROPERTY),
550                 FE(DMUS_E_SET_UNSUPPORTED),
551                 FE(DMUS_E_GET_UNSUPPORTED),
552                 FE(DMUS_E_NOTMONO),
553                 FE(DMUS_E_BADARTICULATION),
554                 FE(DMUS_E_BADINSTRUMENT),
555                 FE(DMUS_E_BADWAVELINK),
556                 FE(DMUS_E_NOARTICULATION),
557                 FE(DMUS_E_NOTPCM),
558                 FE(DMUS_E_BADWAVE),
559                 FE(DMUS_E_BADOFFSETTABLE),
560                 FE(DMUS_E_UNKNOWNDOWNLOAD),
561                 FE(DMUS_E_NOSYNTHSINK),
562                 FE(DMUS_E_ALREADYOPEN),
563                 FE(DMUS_E_ALREADYCLOSED),
564                 FE(DMUS_E_SYNTHNOTCONFIGURED),
565                 FE(DMUS_E_SYNTHACTIVE),
566                 FE(DMUS_E_CANNOTREAD),
567                 FE(DMUS_E_DMUSIC_RELEASED),
568                 FE(DMUS_E_BUFFER_EMPTY),
569                 FE(DMUS_E_BUFFER_FULL),
570                 FE(DMUS_E_PORT_NOT_CAPTURE),
571                 FE(DMUS_E_PORT_NOT_RENDER),
572                 FE(DMUS_E_DSOUND_NOT_SET),
573                 FE(DMUS_E_ALREADY_ACTIVATED),
574                 FE(DMUS_E_INVALIDBUFFER),
575                 FE(DMUS_E_WAVEFORMATNOTSUPPORTED),
576                 FE(DMUS_E_SYNTHINACTIVE),
577                 FE(DMUS_E_DSOUND_ALREADY_SET),
578                 FE(DMUS_E_INVALID_EVENT),
579                 FE(DMUS_E_UNSUPPORTED_STREAM),
580                 FE(DMUS_E_ALREADY_INITED),
581                 FE(DMUS_E_INVALID_BAND),
582                 FE(DMUS_E_TRACK_HDR_NOT_FIRST_CK),
583                 FE(DMUS_E_TOOL_HDR_NOT_FIRST_CK),
584                 FE(DMUS_E_INVALID_TRACK_HDR),
585                 FE(DMUS_E_INVALID_TOOL_HDR),
586                 FE(DMUS_E_ALL_TOOLS_FAILED),
587                 FE(DMUS_E_ALL_TRACKS_FAILED),
588                 FE(DMUS_E_NOT_FOUND),
589                 FE(DMUS_E_NOT_INIT),
590                 FE(DMUS_E_TYPE_DISABLED),
591                 FE(DMUS_E_TYPE_UNSUPPORTED),
592                 FE(DMUS_E_TIME_PAST),
593                 FE(DMUS_E_TRACK_NOT_FOUND),
594                 FE(DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT),
595                 FE(DMUS_E_NO_MASTER_CLOCK),
596                 FE(DMUS_E_LOADER_NOCLASSID),
597                 FE(DMUS_E_LOADER_BADPATH),
598                 FE(DMUS_E_LOADER_FAILEDOPEN),
599                 FE(DMUS_E_LOADER_FORMATNOTSUPPORTED),
600                 FE(DMUS_E_LOADER_FAILEDCREATE),
601                 FE(DMUS_E_LOADER_OBJECTNOTFOUND),
602                 FE(DMUS_E_LOADER_NOFILENAME),
603                 FE(DMUS_E_INVALIDFILE),
604                 FE(DMUS_E_ALREADY_EXISTS),
605                 FE(DMUS_E_OUT_OF_RANGE),
606                 FE(DMUS_E_SEGMENT_INIT_FAILED),
607                 FE(DMUS_E_ALREADY_SENT),
608                 FE(DMUS_E_CANNOT_FREE),
609                 FE(DMUS_E_CANNOT_OPEN_PORT),
610                 FE(DMUS_E_CANNOT_CONVERT),
611                 FE(DMUS_E_DESCEND_CHUNK_FAIL),
612                 FE(DMUS_E_NOT_LOADED),
613                 FE(DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE),
614                 FE(DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE),
615                 FE(DMUS_E_SCRIPT_ERROR_IN_SCRIPT),
616                 FE(DMUS_E_SCRIPT_CANTLOAD_OLEAUT32),
617                 FE(DMUS_E_SCRIPT_LOADSCRIPT_ERROR),
618                 FE(DMUS_E_SCRIPT_INVALID_FILE),
619                 FE(DMUS_E_INVALID_SCRIPTTRACK),
620                 FE(DMUS_E_SCRIPT_VARIABLE_NOT_FOUND),
621                 FE(DMUS_E_SCRIPT_ROUTINE_NOT_FOUND),
622                 FE(DMUS_E_SCRIPT_CONTENT_READONLY),
623                 FE(DMUS_E_SCRIPT_NOT_A_REFERENCE),
624                 FE(DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED),
625                 FE(DMUS_E_INVALID_SEGMENTTRIGGERTRACK),
626                 FE(DMUS_E_INVALID_LYRICSTRACK),
627                 FE(DMUS_E_INVALID_PARAMCONTROLTRACK),
628                 FE(DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR),
629                 FE(DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR),
630                 FE(DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE),
631                 FE(DMUS_E_AUDIOPATHS_NOT_VALID),
632                 FE(DMUS_E_AUDIOPATHS_IN_USE),
633                 FE(DMUS_E_NO_AUDIOPATH_CONFIG),
634                 FE(DMUS_E_AUDIOPATH_INACTIVE),
635                 FE(DMUS_E_AUDIOPATH_NOBUFFER),
636                 FE(DMUS_E_AUDIOPATH_NOPORT),
637                 FE(DMUS_E_NO_AUDIOPATH),
638                 FE(DMUS_E_INVALIDCHUNK),
639                 FE(DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER),
640                 FE(DMUS_E_INVALID_CONTAINER_OBJECT)
641         };
642         unsigned int i;
643         for (i = 0; i < sizeof(codes)/sizeof(codes[0]); i++) {
644                 if (code == codes[i].val)
645                         return codes[i].name;
646         }
647         /* if we didn't find it, return value */
648         return wine_dbg_sprintf("0x%08lx", code);
649 }
650
651 /* generic flag-dumping function */
652 const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
653         char buffer[128] = "", *ptr = &buffer[0];
654         unsigned int i, size = sizeof(buffer);
655         
656         for (i=0; i < num_names; i++)
657         {
658                 if ((flags & names[i].val) ||   /* standard flag*/
659                         ((!flags) && (!names[i].val))) { /* zero value only */
660                                 int cnt = snprintf(ptr, size, "%s ", names[i].name);
661                                 if (cnt < 0 || cnt >= size) break;
662                                 size -= cnt;
663                                 ptr += cnt;
664                 }
665         }
666         
667         return wine_dbg_sprintf("%s", buffer);
668 }
669
670 /* dump DMUS_OBJ flags */
671 const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
672     static const flag_info flags[] = {
673             FE(DMUS_OBJ_OBJECT),
674             FE(DMUS_OBJ_CLASS),
675             FE(DMUS_OBJ_NAME),
676             FE(DMUS_OBJ_CATEGORY),
677             FE(DMUS_OBJ_FILENAME),
678             FE(DMUS_OBJ_FULLPATH),
679             FE(DMUS_OBJ_URL),
680             FE(DMUS_OBJ_VERSION),
681             FE(DMUS_OBJ_DATE),
682             FE(DMUS_OBJ_LOADED),
683             FE(DMUS_OBJ_MEMORY),
684             FE(DMUS_OBJ_STREAM)
685         };
686     return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
687 }
688
689 /* dump whole DMUS_OBJECTDESC struct */
690 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
691         if (pDesc) {
692                 char buffer[1024] = "", *ptr = &buffer[0];
693                 
694                 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
695                 ptr += sprintf(ptr, " - dwSize = %ld\n", pDesc->dwSize);
696                 ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
697                 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
698                 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
699                 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
700                 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
701                 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
702                 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
703                 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
704                 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = %lli\n  - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData);
705                 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
706
707                 return wine_dbg_sprintf("%s", buffer);
708         } else {
709                 return wine_dbg_sprintf("(NULL)");
710         }
711 }