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