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