Moved most remaining file functions to dlls/kernel.
[wine] / dlls / dmstyle / dmstyle_main.c
1 /* DirectMusicStyle 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 "dmstyle_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
23
24 typedef struct {
25     /* IUnknown fields */
26     ICOM_VFIELD(IClassFactory);
27     DWORD                       ref;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicSection ClassFactory
32  */
33 static HRESULT WINAPI SectionCF_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 SectionCF_AddRef(LPCLASSFACTORY iface) {
40         ICOM_THIS(IClassFactoryImpl,iface);
41         return ++(This->ref);
42 }
43
44 static ULONG WINAPI SectionCF_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 SectionCF_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         /* nothing here yet */
54         WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
55         return E_NOINTERFACE;
56 }
57
58 static HRESULT WINAPI SectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
59         ICOM_THIS(IClassFactoryImpl,iface);
60         FIXME("(%p, %d): stub\n", This, dolock);
61         return S_OK;
62 }
63
64 static ICOM_VTABLE(IClassFactory) SectionCF_Vtbl = {
65         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
66         SectionCF_QueryInterface,
67         SectionCF_AddRef,
68         SectionCF_Release,
69         SectionCF_CreateInstance,
70         SectionCF_LockServer
71 };
72
73 static IClassFactoryImpl Section_CF = {&SectionCF_Vtbl, 1 };
74
75 /******************************************************************
76  *              DirectMusicStyle ClassFactory
77  */
78 static HRESULT WINAPI StyleCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
79         ICOM_THIS(IClassFactoryImpl,iface);
80         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
81         return E_NOINTERFACE;
82 }
83
84 static ULONG WINAPI StyleCF_AddRef(LPCLASSFACTORY iface) {
85         ICOM_THIS(IClassFactoryImpl,iface);
86         return ++(This->ref);
87 }
88
89 static ULONG WINAPI StyleCF_Release(LPCLASSFACTORY iface) {
90         ICOM_THIS(IClassFactoryImpl,iface);
91         /* static class, won't be  freed */
92         return --(This->ref);
93 }
94
95 static HRESULT WINAPI StyleCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
96         ICOM_THIS(IClassFactoryImpl,iface);
97         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
98         return DMUSIC_CreateDirectMusicStyleImpl (riid, ppobj, pOuter);
99 }
100
101 static HRESULT WINAPI StyleCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
102         ICOM_THIS(IClassFactoryImpl,iface);
103         FIXME("(%p, %d): stub\n", This, dolock);
104         return S_OK;
105 }
106
107 static ICOM_VTABLE(IClassFactory) StyleCF_Vtbl = {
108         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
109         StyleCF_QueryInterface,
110         StyleCF_AddRef,
111         StyleCF_Release,
112         StyleCF_CreateInstance,
113         StyleCF_LockServer
114 };
115
116 static IClassFactoryImpl Style_CF = {&StyleCF_Vtbl, 1 };
117
118 /******************************************************************
119  *              DirectMusicChordTrack ClassFactory
120  */
121 static HRESULT WINAPI ChordTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
122         ICOM_THIS(IClassFactoryImpl,iface);
123         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
124         return E_NOINTERFACE;
125 }
126
127 static ULONG WINAPI ChordTrackCF_AddRef(LPCLASSFACTORY iface) {
128         ICOM_THIS(IClassFactoryImpl,iface);
129         return ++(This->ref);
130 }
131
132 static ULONG WINAPI ChordTrackCF_Release(LPCLASSFACTORY iface) {
133         ICOM_THIS(IClassFactoryImpl,iface);
134         /* static class, won't be  freed */
135         return --(This->ref);
136 }
137
138 static HRESULT WINAPI ChordTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
139         ICOM_THIS(IClassFactoryImpl,iface);
140         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
141         return DMUSIC_CreateDirectMusicChordTrack (riid, ppobj, pOuter);
142 }
143
144 static HRESULT WINAPI ChordTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
145         ICOM_THIS(IClassFactoryImpl,iface);
146         FIXME("(%p, %d): stub\n", This, dolock);
147         return S_OK;
148 }
149
150 static ICOM_VTABLE(IClassFactory) ChordTrackCF_Vtbl = {
151         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
152         ChordTrackCF_QueryInterface,
153         ChordTrackCF_AddRef,
154         ChordTrackCF_Release,
155         ChordTrackCF_CreateInstance,
156         ChordTrackCF_LockServer
157 };
158
159 static IClassFactoryImpl ChordTrack_CF = {&ChordTrackCF_Vtbl, 1 };
160
161 /******************************************************************
162  *              DirectMusicCommandTrack ClassFactory
163  */
164 static HRESULT WINAPI CommandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
165         ICOM_THIS(IClassFactoryImpl,iface);
166         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
167         return E_NOINTERFACE;
168 }
169
170 static ULONG WINAPI CommandTrackCF_AddRef(LPCLASSFACTORY iface) {
171         ICOM_THIS(IClassFactoryImpl,iface);
172         return ++(This->ref);
173 }
174
175 static ULONG WINAPI CommandTrackCF_Release(LPCLASSFACTORY iface) {
176         ICOM_THIS(IClassFactoryImpl,iface);
177         /* static class, won't be  freed */
178         return --(This->ref);
179 }
180
181 static HRESULT WINAPI CommandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
182         ICOM_THIS(IClassFactoryImpl,iface);
183         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
184         return DMUSIC_CreateDirectMusicCommandTrack (riid, ppobj, pOuter);
185 }
186
187 static HRESULT WINAPI CommandTrackCF_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) CommandTrackCF_Vtbl = {
194         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
195         CommandTrackCF_QueryInterface,
196         CommandTrackCF_AddRef,
197         CommandTrackCF_Release,
198         CommandTrackCF_CreateInstance,
199         CommandTrackCF_LockServer
200 };
201
202 static IClassFactoryImpl CommandTrack_CF = {&CommandTrackCF_Vtbl, 1 };
203
204 /******************************************************************
205  *              DirectMusicStyleTrack ClassFactory
206  */
207 static HRESULT WINAPI StyleTrackCF_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 StyleTrackCF_AddRef(LPCLASSFACTORY iface) {
214         ICOM_THIS(IClassFactoryImpl,iface);
215         return ++(This->ref);
216 }
217
218 static ULONG WINAPI StyleTrackCF_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 StyleTrackCF_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_CreateDirectMusicStyleTrack (riid, ppobj, pOuter);
228 }
229
230 static HRESULT WINAPI StyleTrackCF_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) StyleTrackCF_Vtbl = {
237         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
238         StyleTrackCF_QueryInterface,
239         StyleTrackCF_AddRef,
240         StyleTrackCF_Release,
241         StyleTrackCF_CreateInstance,
242         StyleTrackCF_LockServer
243 };
244
245 static IClassFactoryImpl StyleTrack_CF = {&StyleTrackCF_Vtbl, 1 };
246
247 /******************************************************************
248  *              DirectMusicMotifTrack ClassFactory
249  */
250 static HRESULT WINAPI MotifTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
251         ICOM_THIS(IClassFactoryImpl,iface);
252         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
253         return E_NOINTERFACE;
254 }
255
256 static ULONG WINAPI MotifTrackCF_AddRef(LPCLASSFACTORY iface) {
257         ICOM_THIS(IClassFactoryImpl,iface);
258         return ++(This->ref);
259 }
260
261 static ULONG WINAPI MotifTrackCF_Release(LPCLASSFACTORY iface) {
262         ICOM_THIS(IClassFactoryImpl,iface);
263         /* static class, won't be  freed */
264         return --(This->ref);
265 }
266
267 static HRESULT WINAPI MotifTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
268         ICOM_THIS(IClassFactoryImpl,iface);
269         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
270         return DMUSIC_CreateDirectMusicMotifTrack (riid, ppobj, pOuter);
271 }
272
273 static HRESULT WINAPI MotifTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
274         ICOM_THIS(IClassFactoryImpl,iface);
275         FIXME("(%p, %d): stub\n", This, dolock);
276         return S_OK;
277 }
278
279 static ICOM_VTABLE(IClassFactory) MotifTrackCF_Vtbl = {
280         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
281         MotifTrackCF_QueryInterface,
282         MotifTrackCF_AddRef,
283         MotifTrackCF_Release,
284         MotifTrackCF_CreateInstance,
285         MotifTrackCF_LockServer
286 };
287
288 static IClassFactoryImpl MotifTrack_CF = {&MotifTrackCF_Vtbl, 1 };
289
290 /******************************************************************
291  *              DirectMusicAuditionTrack ClassFactory
292  */
293 static HRESULT WINAPI AuditionTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
294         ICOM_THIS(IClassFactoryImpl,iface);
295         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
296         return E_NOINTERFACE;
297 }
298
299 static ULONG WINAPI AuditionTrackCF_AddRef(LPCLASSFACTORY iface) {
300         ICOM_THIS(IClassFactoryImpl,iface);
301         return ++(This->ref);
302 }
303
304 static ULONG WINAPI AuditionTrackCF_Release(LPCLASSFACTORY iface) {
305         ICOM_THIS(IClassFactoryImpl,iface);
306         /* static class, won't be  freed */
307         return --(This->ref);
308 }
309
310 static HRESULT WINAPI AuditionTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
311         ICOM_THIS(IClassFactoryImpl,iface);
312         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
313         return DMUSIC_CreateDirectMusicAuditionTrack (riid, ppobj, pOuter);
314 }
315
316 static HRESULT WINAPI AuditionTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
317         ICOM_THIS(IClassFactoryImpl,iface);
318         FIXME("(%p, %d): stub\n", This, dolock);
319         return S_OK;
320 }
321
322 static ICOM_VTABLE(IClassFactory) AuditionTrackCF_Vtbl = {
323         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
324         AuditionTrackCF_QueryInterface,
325         AuditionTrackCF_AddRef,
326         AuditionTrackCF_Release,
327         AuditionTrackCF_CreateInstance,
328         AuditionTrackCF_LockServer
329 };
330
331 static IClassFactoryImpl AuditionTrack_CF = {&AuditionTrackCF_Vtbl, 1 };
332
333 /******************************************************************
334  *              DirectMusicMuteTrack ClassFactory
335  */
336 static HRESULT WINAPI MuteTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
337         ICOM_THIS(IClassFactoryImpl,iface);
338         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
339         return E_NOINTERFACE;
340 }
341
342 static ULONG WINAPI MuteTrackCF_AddRef(LPCLASSFACTORY iface) {
343         ICOM_THIS(IClassFactoryImpl,iface);
344         return ++(This->ref);
345 }
346
347 static ULONG WINAPI MuteTrackCF_Release(LPCLASSFACTORY iface) {
348         ICOM_THIS(IClassFactoryImpl,iface);
349         /* static class, won't be  freed */
350         return --(This->ref);
351 }
352
353 static HRESULT WINAPI MuteTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
354         ICOM_THIS(IClassFactoryImpl,iface);
355         TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
356         return DMUSIC_CreateDirectMusicMuteTrack (riid, ppobj, pOuter);
357 }
358
359 static HRESULT WINAPI MuteTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
360         ICOM_THIS(IClassFactoryImpl,iface);
361         FIXME("(%p, %d): stub\n", This, dolock);
362         return S_OK;
363 }
364
365 static ICOM_VTABLE(IClassFactory) MuteTrackCF_Vtbl = {
366         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
367         MuteTrackCF_QueryInterface,
368         MuteTrackCF_AddRef,
369         MuteTrackCF_Release,
370         MuteTrackCF_CreateInstance,
371         MuteTrackCF_LockServer
372 };
373
374 static IClassFactoryImpl MuteTrack_CF = {&MuteTrackCF_Vtbl, 1 };
375
376 /******************************************************************
377  *              DllMain
378  *
379  *
380  */
381 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
382         if (fdwReason == DLL_PROCESS_ATTACH) {
383             DisableThreadLibraryCalls(hinstDLL);
384                 /* FIXME: Initialisation */
385         } else if (fdwReason == DLL_PROCESS_DETACH) {
386                 /* FIXME: Cleanup */
387         }
388
389         return TRUE;
390 }
391
392
393 /******************************************************************
394  *              DllCanUnloadNow (DMSTYLE.1)
395  *
396  *
397  */
398 HRESULT WINAPI DMSTYLE_DllCanUnloadNow(void) {
399     FIXME("(void): stub\n");
400     return S_FALSE;
401 }
402
403
404 /******************************************************************
405  *              DllGetClassObject (DMSTYLE.2)
406  *
407  *
408  */
409 HRESULT WINAPI DMSTYLE_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
410     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
411     
412         if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSection) && IsEqualIID (riid, &IID_IClassFactory)) {
413                 *ppv = (LPVOID) &Section_CF;
414                 IClassFactory_AddRef((IClassFactory*)*ppv);
415                 return S_OK;
416         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyle) && IsEqualIID (riid, &IID_IClassFactory)) {
417                 *ppv = (LPVOID) &Style_CF;
418                 IClassFactory_AddRef((IClassFactory*)*ppv);
419                 return S_OK;            
420         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
421                 *ppv = (LPVOID) &ChordTrack_CF;
422                 IClassFactory_AddRef((IClassFactory*)*ppv);
423                 return S_OK;    
424         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCommandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
425                 *ppv = (LPVOID) &CommandTrack_CF;
426                 IClassFactory_AddRef((IClassFactory*)*ppv);
427                 return S_OK;            
428         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyleTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
429                 *ppv = (LPVOID) &StyleTrack_CF;
430                 IClassFactory_AddRef((IClassFactory*)*ppv);
431                 return S_OK;            
432         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMotifTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
433                 *ppv = (LPVOID) &MotifTrack_CF;
434                 IClassFactory_AddRef((IClassFactory*)*ppv);
435                 return S_OK;            
436         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAuditionTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
437                 *ppv = (LPVOID) &AuditionTrack_CF;
438                 IClassFactory_AddRef((IClassFactory*)*ppv);
439                 return S_OK;            
440         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMuteTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
441                 *ppv = (LPVOID) &MuteTrack_CF;
442                 IClassFactory_AddRef((IClassFactory*)*ppv);
443                 return S_OK;            
444         }
445
446     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
447     return CLASS_E_CLASSNOTAVAILABLE;
448 }
449
450
451 /******************************************************************
452  *              Helper functions
453  *
454  *
455  */
456 /* check whether the given DWORD is even (return 0) or odd (return 1) */
457 int even_or_odd (DWORD number) {
458         return (number & 0x1); /* basically, check if bit 0 is set ;) */
459 }
460
461 /* FOURCC to string conversion for debug messages */
462 const char *debugstr_fourcc (DWORD fourcc) {
463     if (!fourcc) return "'null'";
464     return wine_dbg_sprintf ("\'%c%c%c%c\'",
465                 (char)(fourcc), (char)(fourcc >> 8),
466         (char)(fourcc >> 16), (char)(fourcc >> 24));
467 }
468
469 /* DMUS_VERSION struct to string conversion for debug messages */
470 const char *debugstr_dmversion (LPDMUS_VERSION version) {
471         if (!version) return "'null'";
472         return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
473                 (int)((version->dwVersionMS && 0xFFFF0000) >> 8), (int)(version->dwVersionMS && 0x0000FFFF), 
474                 (int)((version->dwVersionLS && 0xFFFF0000) >> 8), (int)(version->dwVersionLS && 0x0000FFFF));
475 }
476
477 /* returns name of given GUID */
478 const char *debugstr_dmguid (const GUID *id) {
479         static const guid_info guids[] = {
480                 /* CLSIDs */
481                 GE(CLSID_AudioVBScript),
482                 GE(CLSID_DirectMusic),
483                 GE(CLSID_DirectMusicAudioPath),
484                 GE(CLSID_DirectMusicAudioPathConfig),
485                 GE(CLSID_DirectMusicAuditionTrack),
486                 GE(CLSID_DirectMusicBand),
487                 GE(CLSID_DirectMusicBandTrack),
488                 GE(CLSID_DirectMusicChordMapTrack),
489                 GE(CLSID_DirectMusicChordMap),
490                 GE(CLSID_DirectMusicChordTrack),
491                 GE(CLSID_DirectMusicCollection),
492                 GE(CLSID_DirectMusicCommandTrack),
493                 GE(CLSID_DirectMusicComposer),
494                 GE(CLSID_DirectMusicContainer),
495                 GE(CLSID_DirectMusicGraph),
496                 GE(CLSID_DirectMusicLoader),
497                 GE(CLSID_DirectMusicLyricsTrack),
498                 GE(CLSID_DirectMusicMarkerTrack),
499                 GE(CLSID_DirectMusicMelodyFormulationTrack),
500                 GE(CLSID_DirectMusicMotifTrack),
501                 GE(CLSID_DirectMusicMuteTrack),
502                 GE(CLSID_DirectMusicParamControlTrack),
503                 GE(CLSID_DirectMusicPatternTrack),
504                 GE(CLSID_DirectMusicPerformance),
505                 GE(CLSID_DirectMusicScript),
506                 GE(CLSID_DirectMusicScriptAutoImpSegment),
507                 GE(CLSID_DirectMusicScriptAutoImpPerformance),
508                 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
509                 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
510                 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
511                 GE(CLSID_DirectMusicScriptAutoImpSong),
512                 GE(CLSID_DirectMusicScriptSourceCodeLoader),
513                 GE(CLSID_DirectMusicScriptTrack),
514                 GE(CLSID_DirectMusicSection),
515                 GE(CLSID_DirectMusicSegment),
516                 GE(CLSID_DirectMusicSegmentState),
517                 GE(CLSID_DirectMusicSegmentTriggerTrack),
518                 GE(CLSID_DirectMusicSegTriggerTrack),
519                 GE(CLSID_DirectMusicSeqTrack),
520                 GE(CLSID_DirectMusicSignPostTrack),
521                 GE(CLSID_DirectMusicSong),
522                 GE(CLSID_DirectMusicStyle),
523                 GE(CLSID_DirectMusicStyleTrack),
524                 GE(CLSID_DirectMusicSynth),
525                 GE(CLSID_DirectMusicSynthSink),
526                 GE(CLSID_DirectMusicSysExTrack),
527                 GE(CLSID_DirectMusicTemplate),
528                 GE(CLSID_DirectMusicTempoTrack),
529                 GE(CLSID_DirectMusicTimeSigTrack),
530                 GE(CLSID_DirectMusicWaveTrack),
531                 GE(CLSID_DirectSoundWave),
532                 /* IIDs */
533                 GE(IID_IDirectMusic),
534                 GE(IID_IDirectMusic2),
535                 GE(IID_IDirectMusic8),
536                 GE(IID_IDirectMusicAudioPath),
537                 GE(IID_IDirectMusicBand),
538                 GE(IID_IDirectMusicBuffer),
539                 GE(IID_IDirectMusicChordMap),
540                 GE(IID_IDirectMusicCollection),
541                 GE(IID_IDirectMusicComposer),
542                 GE(IID_IDirectMusicContainer),
543                 GE(IID_IDirectMusicDownload),
544                 GE(IID_IDirectMusicDownloadedInstrument),
545                 GE(IID_IDirectMusicGetLoader),
546                 GE(IID_IDirectMusicGraph),
547                 GE(IID_IDirectMusicInstrument),
548                 GE(IID_IDirectMusicLoader),
549                 GE(IID_IDirectMusicLoader8),
550                 GE(IID_IDirectMusicObject),
551                 GE(IID_IDirectMusicPatternTrack),
552                 GE(IID_IDirectMusicPerformance),
553                 GE(IID_IDirectMusicPerformance2),
554                 GE(IID_IDirectMusicPerformance8),
555                 GE(IID_IDirectMusicPort),
556                 GE(IID_IDirectMusicPortDownload),
557                 GE(IID_IDirectMusicScript),
558                 GE(IID_IDirectMusicSegment),
559                 GE(IID_IDirectMusicSegment2),
560                 GE(IID_IDirectMusicSegment8),
561                 GE(IID_IDirectMusicSegmentState),
562                 GE(IID_IDirectMusicSegmentState8),
563                 GE(IID_IDirectMusicStyle),
564                 GE(IID_IDirectMusicStyle8),
565                 GE(IID_IDirectMusicSynth),
566                 GE(IID_IDirectMusicSynth8),
567                 GE(IID_IDirectMusicSynthSink),
568                 GE(IID_IDirectMusicThru),
569                 GE(IID_IDirectMusicTool),
570                 GE(IID_IDirectMusicTool8),
571                 GE(IID_IDirectMusicTrack),
572                 GE(IID_IDirectMusicTrack8),
573                 GE(IID_IUnknown),
574                 GE(IID_IPersistStream),
575                 GE(IID_IStream),
576                 /* GUIDs */
577                 GE(GUID_DirectMusicAllTypes),
578                 GE(GUID_NOTIFICATION_CHORD),
579                 GE(GUID_NOTIFICATION_COMMAND),
580                 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
581                 GE(GUID_NOTIFICATION_PERFORMANCE),
582                 GE(GUID_NOTIFICATION_RECOMPOSE),
583                 GE(GUID_NOTIFICATION_SEGMENT),
584                 GE(GUID_BandParam),
585                 GE(GUID_ChordParam),
586                 GE(GUID_CommandParam),
587                 GE(GUID_CommandParam2),
588                 GE(GUID_CommandParamNext),
589                 GE(GUID_IDirectMusicBand),
590                 GE(GUID_IDirectMusicChordMap),
591                 GE(GUID_IDirectMusicStyle),
592                 GE(GUID_MuteParam),
593                 GE(GUID_Play_Marker),
594                 GE(GUID_RhythmParam),
595                 GE(GUID_TempoParam),
596                 GE(GUID_TimeSignature),
597                 GE(GUID_Valid_Start_Time),
598                 GE(GUID_Clear_All_Bands),
599                 GE(GUID_ConnectToDLSCollection),
600                 GE(GUID_Disable_Auto_Download),
601                 GE(GUID_DisableTempo),
602                 GE(GUID_DisableTimeSig),
603                 GE(GUID_Download),
604                 GE(GUID_DownloadToAudioPath),
605                 GE(GUID_Enable_Auto_Download),
606                 GE(GUID_EnableTempo),
607                 GE(GUID_EnableTimeSig),
608                 GE(GUID_IgnoreBankSelectForGM),
609                 GE(GUID_SeedVariations),
610                 GE(GUID_StandardMIDIFile),
611                 GE(GUID_Unload),
612                 GE(GUID_UnloadFromAudioPath),
613                 GE(GUID_Variations),
614                 GE(GUID_PerfMasterTempo),
615                 GE(GUID_PerfMasterVolume),
616                 GE(GUID_PerfMasterGrooveLevel),
617                 GE(GUID_PerfAutoDownload),
618                 GE(GUID_DefaultGMCollection),
619                 GE(GUID_Synth_Default),
620                 GE(GUID_Buffer_Reverb),
621                 GE(GUID_Buffer_EnvReverb),
622                 GE(GUID_Buffer_Stereo),
623                 GE(GUID_Buffer_3D_Dry),
624                 GE(GUID_Buffer_Mono),
625                 GE(GUID_DMUS_PROP_GM_Hardware),
626                 GE(GUID_DMUS_PROP_GS_Capable),
627                 GE(GUID_DMUS_PROP_GS_Hardware),
628                 GE(GUID_DMUS_PROP_DLS1),
629                 GE(GUID_DMUS_PROP_DLS2),
630                 GE(GUID_DMUS_PROP_Effects),
631                 GE(GUID_DMUS_PROP_INSTRUMENT2),
632                 GE(GUID_DMUS_PROP_LegacyCaps),
633                 GE(GUID_DMUS_PROP_MemorySize),
634                 GE(GUID_DMUS_PROP_SampleMemorySize),
635                 GE(GUID_DMUS_PROP_SamplePlaybackRate),
636                 GE(GUID_DMUS_PROP_SetSynthSink),
637                 GE(GUID_DMUS_PROP_SinkUsesDSound),
638                 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
639                 GE(GUID_DMUS_PROP_SynthSink_WAVE),
640                 GE(GUID_DMUS_PROP_Volume),
641                 GE(GUID_DMUS_PROP_WavesReverb),
642                 GE(GUID_DMUS_PROP_WriteLatency),
643                 GE(GUID_DMUS_PROP_WritePeriod),
644                 GE(GUID_DMUS_PROP_XG_Capable),
645                 GE(GUID_DMUS_PROP_XG_Hardware)
646         };
647
648         unsigned int i;
649
650         if (!id) return "(null)";
651
652         for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
653                 if (IsEqualGUID(id, &guids[i].guid))
654                         return guids[i].name;
655         }
656         /* if we didn't find it, act like standard debugstr_guid */     
657         return debugstr_guid(id);
658 }       
659
660 /* returns name of given error code */
661 const char *debugstr_dmreturn (DWORD code) {
662         static const flag_info codes[] = {
663                 FE(S_OK),
664                 FE(S_FALSE),
665                 FE(DMUS_S_PARTIALLOAD),
666                 FE(DMUS_S_PARTIALDOWNLOAD),
667                 FE(DMUS_S_REQUEUE),
668                 FE(DMUS_S_FREE),
669                 FE(DMUS_S_END),
670                 FE(DMUS_S_STRING_TRUNCATED),
671                 FE(DMUS_S_LAST_TOOL),
672                 FE(DMUS_S_OVER_CHORD),
673                 FE(DMUS_S_UP_OCTAVE),
674                 FE(DMUS_S_DOWN_OCTAVE),
675                 FE(DMUS_S_NOBUFFERCONTROL),
676                 FE(DMUS_S_GARBAGE_COLLECTED),
677                 FE(DMUS_E_DRIVER_FAILED),
678                 FE(DMUS_E_PORTS_OPEN),
679                 FE(DMUS_E_DEVICE_IN_USE),
680                 FE(DMUS_E_INSUFFICIENTBUFFER),
681                 FE(DMUS_E_BUFFERNOTSET),
682                 FE(DMUS_E_BUFFERNOTAVAILABLE),
683                 FE(DMUS_E_NOTADLSCOL),
684                 FE(DMUS_E_INVALIDOFFSET),
685                 FE(DMUS_E_ALREADY_LOADED),
686                 FE(DMUS_E_INVALIDPOS),
687                 FE(DMUS_E_INVALIDPATCH),
688                 FE(DMUS_E_CANNOTSEEK),
689                 FE(DMUS_E_CANNOTWRITE),
690                 FE(DMUS_E_CHUNKNOTFOUND),
691                 FE(DMUS_E_INVALID_DOWNLOADID),
692                 FE(DMUS_E_NOT_DOWNLOADED_TO_PORT),
693                 FE(DMUS_E_ALREADY_DOWNLOADED),
694                 FE(DMUS_E_UNKNOWN_PROPERTY),
695                 FE(DMUS_E_SET_UNSUPPORTED),
696                 FE(DMUS_E_GET_UNSUPPORTED),
697                 FE(DMUS_E_NOTMONO),
698                 FE(DMUS_E_BADARTICULATION),
699                 FE(DMUS_E_BADINSTRUMENT),
700                 FE(DMUS_E_BADWAVELINK),
701                 FE(DMUS_E_NOARTICULATION),
702                 FE(DMUS_E_NOTPCM),
703                 FE(DMUS_E_BADWAVE),
704                 FE(DMUS_E_BADOFFSETTABLE),
705                 FE(DMUS_E_UNKNOWNDOWNLOAD),
706                 FE(DMUS_E_NOSYNTHSINK),
707                 FE(DMUS_E_ALREADYOPEN),
708                 FE(DMUS_E_ALREADYCLOSED),
709                 FE(DMUS_E_SYNTHNOTCONFIGURED),
710                 FE(DMUS_E_SYNTHACTIVE),
711                 FE(DMUS_E_CANNOTREAD),
712                 FE(DMUS_E_DMUSIC_RELEASED),
713                 FE(DMUS_E_BUFFER_EMPTY),
714                 FE(DMUS_E_BUFFER_FULL),
715                 FE(DMUS_E_PORT_NOT_CAPTURE),
716                 FE(DMUS_E_PORT_NOT_RENDER),
717                 FE(DMUS_E_DSOUND_NOT_SET),
718                 FE(DMUS_E_ALREADY_ACTIVATED),
719                 FE(DMUS_E_INVALIDBUFFER),
720                 FE(DMUS_E_WAVEFORMATNOTSUPPORTED),
721                 FE(DMUS_E_SYNTHINACTIVE),
722                 FE(DMUS_E_DSOUND_ALREADY_SET),
723                 FE(DMUS_E_INVALID_EVENT),
724                 FE(DMUS_E_UNSUPPORTED_STREAM),
725                 FE(DMUS_E_ALREADY_INITED),
726                 FE(DMUS_E_INVALID_BAND),
727                 FE(DMUS_E_TRACK_HDR_NOT_FIRST_CK),
728                 FE(DMUS_E_TOOL_HDR_NOT_FIRST_CK),
729                 FE(DMUS_E_INVALID_TRACK_HDR),
730                 FE(DMUS_E_INVALID_TOOL_HDR),
731                 FE(DMUS_E_ALL_TOOLS_FAILED),
732                 FE(DMUS_E_ALL_TRACKS_FAILED),
733                 FE(DMUS_E_NOT_FOUND),
734                 FE(DMUS_E_NOT_INIT),
735                 FE(DMUS_E_TYPE_DISABLED),
736                 FE(DMUS_E_TYPE_UNSUPPORTED),
737                 FE(DMUS_E_TIME_PAST),
738                 FE(DMUS_E_TRACK_NOT_FOUND),
739                 FE(DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT),
740                 FE(DMUS_E_NO_MASTER_CLOCK),
741                 FE(DMUS_E_LOADER_NOCLASSID),
742                 FE(DMUS_E_LOADER_BADPATH),
743                 FE(DMUS_E_LOADER_FAILEDOPEN),
744                 FE(DMUS_E_LOADER_FORMATNOTSUPPORTED),
745                 FE(DMUS_E_LOADER_FAILEDCREATE),
746                 FE(DMUS_E_LOADER_OBJECTNOTFOUND),
747                 FE(DMUS_E_LOADER_NOFILENAME),
748                 FE(DMUS_E_INVALIDFILE),
749                 FE(DMUS_E_ALREADY_EXISTS),
750                 FE(DMUS_E_OUT_OF_RANGE),
751                 FE(DMUS_E_SEGMENT_INIT_FAILED),
752                 FE(DMUS_E_ALREADY_SENT),
753                 FE(DMUS_E_CANNOT_FREE),
754                 FE(DMUS_E_CANNOT_OPEN_PORT),
755                 FE(DMUS_E_CANNOT_CONVERT),
756                 FE(DMUS_E_DESCEND_CHUNK_FAIL),
757                 FE(DMUS_E_NOT_LOADED),
758                 FE(DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE),
759                 FE(DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE),
760                 FE(DMUS_E_SCRIPT_ERROR_IN_SCRIPT),
761                 FE(DMUS_E_SCRIPT_CANTLOAD_OLEAUT32),
762                 FE(DMUS_E_SCRIPT_LOADSCRIPT_ERROR),
763                 FE(DMUS_E_SCRIPT_INVALID_FILE),
764                 FE(DMUS_E_INVALID_SCRIPTTRACK),
765                 FE(DMUS_E_SCRIPT_VARIABLE_NOT_FOUND),
766                 FE(DMUS_E_SCRIPT_ROUTINE_NOT_FOUND),
767                 FE(DMUS_E_SCRIPT_CONTENT_READONLY),
768                 FE(DMUS_E_SCRIPT_NOT_A_REFERENCE),
769                 FE(DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED),
770                 FE(DMUS_E_INVALID_SEGMENTTRIGGERTRACK),
771                 FE(DMUS_E_INVALID_LYRICSTRACK),
772                 FE(DMUS_E_INVALID_PARAMCONTROLTRACK),
773                 FE(DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR),
774                 FE(DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR),
775                 FE(DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE),
776                 FE(DMUS_E_AUDIOPATHS_NOT_VALID),
777                 FE(DMUS_E_AUDIOPATHS_IN_USE),
778                 FE(DMUS_E_NO_AUDIOPATH_CONFIG),
779                 FE(DMUS_E_AUDIOPATH_INACTIVE),
780                 FE(DMUS_E_AUDIOPATH_NOBUFFER),
781                 FE(DMUS_E_AUDIOPATH_NOPORT),
782                 FE(DMUS_E_NO_AUDIOPATH),
783                 FE(DMUS_E_INVALIDCHUNK),
784                 FE(DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER),
785                 FE(DMUS_E_INVALID_CONTAINER_OBJECT)
786         };
787         unsigned int i;
788         for (i = 0; i < sizeof(codes)/sizeof(codes[0]); i++) {
789                 if (code == codes[i].val)
790                         return codes[i].name;
791         }
792         /* if we didn't find it, return value */
793         return wine_dbg_sprintf("0x%08lx", code);
794 }
795
796 /* generic flag-dumping function */
797 const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
798         char buffer[128] = "", *ptr = &buffer[0];
799         unsigned int i, size = sizeof(buffer);
800         
801         for (i=0; i < num_names; i++)
802         {
803                 if ((flags & names[i].val) ||   /* standard flag*/
804                         ((!flags) && (!names[i].val))) { /* zero value only */
805                                 int cnt = snprintf(ptr, size, "%s ", names[i].name);
806                                 if (cnt < 0 || cnt >= size) break;
807                                 size -= cnt;
808                                 ptr += cnt;
809                 }
810         }
811         
812         return wine_dbg_sprintf("%s", buffer);
813 }
814
815 /* dump DMUS_OBJ flags */
816 const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
817     static const flag_info flags[] = {
818             FE(DMUS_OBJ_OBJECT),
819             FE(DMUS_OBJ_CLASS),
820             FE(DMUS_OBJ_NAME),
821             FE(DMUS_OBJ_CATEGORY),
822             FE(DMUS_OBJ_FILENAME),
823             FE(DMUS_OBJ_FULLPATH),
824             FE(DMUS_OBJ_URL),
825             FE(DMUS_OBJ_VERSION),
826             FE(DMUS_OBJ_DATE),
827             FE(DMUS_OBJ_LOADED),
828             FE(DMUS_OBJ_MEMORY),
829             FE(DMUS_OBJ_STREAM)
830         };
831     return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
832 }
833
834 /* dump whole DMUS_OBJECTDESC struct */
835 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
836         if (pDesc) {
837                 char buffer[1024] = "", *ptr = &buffer[0];
838                 
839                 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
840                 ptr += sprintf(ptr, " - dwSize = %ld\n", pDesc->dwSize);
841                 ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
842                 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
843                 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
844                 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
845                 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
846                 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
847                 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
848                 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
849                 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = %lli\n  - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData);
850                 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
851
852                 return wine_dbg_sprintf("%s", buffer);
853         } else {
854                 return wine_dbg_sprintf("(NULL)");
855         }
856 }