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