3 * Copyright (C) 2003-2004 Rok Mandeljc
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.
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.
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.
22 #include "dmusic_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
28 IClassFactoryVtbl *lpVtbl;
32 /******************************************************************
33 * DirectMusic ClassFactory
35 static HRESULT WINAPI DirectMusicCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
36 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
37 FIXME("(%p, %s, %p): stub\n",This,debugstr_dmguid(riid),ppobj);
41 static ULONG WINAPI DirectMusicCF_AddRef(LPCLASSFACTORY iface) {
42 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
46 static ULONG WINAPI DirectMusicCF_Release(LPCLASSFACTORY iface) {
47 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
48 /* static class, won't be freed */
52 static HRESULT WINAPI DirectMusicCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
53 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
54 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
55 return DMUSIC_CreateDirectMusicImpl (riid, (LPVOID*) ppobj, pOuter);
58 static HRESULT WINAPI DirectMusicCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
59 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
60 FIXME("(%p, %d): stub\n", This, dolock);
64 static IClassFactoryVtbl DirectMusicCF_Vtbl = {
65 DirectMusicCF_QueryInterface,
67 DirectMusicCF_Release,
68 DirectMusicCF_CreateInstance,
69 DirectMusicCF_LockServer
72 static IClassFactoryImpl DirectMusic_CF = {&DirectMusicCF_Vtbl, 1 };
74 /******************************************************************
75 * DirectMusicCollection ClassFactory
77 static HRESULT WINAPI CollectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
78 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
79 FIXME("(%p, %s, %p): stub\n",This,debugstr_dmguid(riid),ppobj);
83 static ULONG WINAPI CollectionCF_AddRef(LPCLASSFACTORY iface) {
84 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
88 static ULONG WINAPI CollectionCF_Release(LPCLASSFACTORY iface) {
89 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
90 /* static class, won't be freed */
94 static HRESULT WINAPI CollectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
95 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
96 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
97 return DMUSIC_CreateDirectMusicCollectionImpl (riid, ppobj, pOuter);
100 static HRESULT WINAPI CollectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
101 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
102 FIXME("(%p, %d): stub\n", This, dolock);
106 static IClassFactoryVtbl CollectionCF_Vtbl = {
107 CollectionCF_QueryInterface,
109 CollectionCF_Release,
110 CollectionCF_CreateInstance,
111 CollectionCF_LockServer
114 static IClassFactoryImpl Collection_CF = {&CollectionCF_Vtbl, 1 };
116 /******************************************************************
121 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
122 if (fdwReason == DLL_PROCESS_ATTACH) {
123 DisableThreadLibraryCalls(hinstDLL);
124 /* FIXME: Initialisation */
125 } else if (fdwReason == DLL_PROCESS_DETACH) {
133 /******************************************************************
134 * DllCanUnloadNow (DMUSIC.1)
138 HRESULT WINAPI DMUSIC_DllCanUnloadNow(void) {
139 FIXME("(void): stub\n");
144 /******************************************************************
145 * DllGetClassObject (DMUSIC.2)
149 HRESULT WINAPI DMUSIC_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
150 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
151 if (IsEqualCLSID (rclsid, &CLSID_DirectMusic) && IsEqualIID (riid, &IID_IClassFactory)) {
152 *ppv = (LPVOID) &DirectMusic_CF;
153 IClassFactory_AddRef((IClassFactory*)*ppv);
155 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCollection) && IsEqualIID (riid, &IID_IClassFactory)) {
156 *ppv = (LPVOID) &Collection_CF;
157 IClassFactory_AddRef((IClassFactory*)*ppv);
161 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
162 return CLASS_E_CLASSNOTAVAILABLE;
166 /******************************************************************
171 /* dwPatch from MIDILOCALE */
172 DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale) {
174 if (!pLocale) return 0;
175 dwPatch |= (pLocale->ulBank & F_INSTRUMENT_DRUMS); /* set drum bit */
176 dwPatch |= ((pLocale->ulBank & 0x00007F7F) << 8); /* set MIDI bank location */
177 dwPatch |= (pLocale->ulInstrument & 0x0000007F); /* set PC value */
181 /* MIDILOCALE from dwPatch */
182 void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) {
183 memset (pLocale, 0, sizeof(MIDILOCALE));
185 pLocale->ulInstrument = (dwPatch & 0x7F); /* get PC value */
186 pLocale->ulBank = ((dwPatch & 0x007F7F00) >> 8); /* get MIDI bank location */
187 pLocale->ulBank |= (dwPatch & F_INSTRUMENT_DRUMS); /* get drum bit */
190 /* check whether the given DWORD is even (return 0) or odd (return 1) */
191 int even_or_odd (DWORD number) {
192 return (number & 0x1); /* basically, check if bit 0 is set ;) */
195 /* FOURCC to string conversion for debug messages */
196 const char *debugstr_fourcc (DWORD fourcc) {
197 if (!fourcc) return "'null'";
198 return wine_dbg_sprintf ("\'%c%c%c%c\'",
199 (char)(fourcc), (char)(fourcc >> 8),
200 (char)(fourcc >> 16), (char)(fourcc >> 24));
203 /* DMUS_VERSION struct to string conversion for debug messages */
204 const char *debugstr_dmversion (LPDMUS_VERSION version) {
205 if (!version) return "'null'";
206 return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
207 (int)((version->dwVersionMS && 0xFFFF0000) >> 8), (int)(version->dwVersionMS && 0x0000FFFF),
208 (int)((version->dwVersionLS && 0xFFFF0000) >> 8), (int)(version->dwVersionLS && 0x0000FFFF));
211 /* returns name of given GUID */
212 const char *debugstr_dmguid (const GUID *id) {
213 static const guid_info guids[] = {
215 GE(CLSID_AudioVBScript),
216 GE(CLSID_DirectMusic),
217 GE(CLSID_DirectMusicAudioPath),
218 GE(CLSID_DirectMusicAudioPathConfig),
219 GE(CLSID_DirectMusicAuditionTrack),
220 GE(CLSID_DirectMusicBand),
221 GE(CLSID_DirectMusicBandTrack),
222 GE(CLSID_DirectMusicChordMapTrack),
223 GE(CLSID_DirectMusicChordMap),
224 GE(CLSID_DirectMusicChordTrack),
225 GE(CLSID_DirectMusicCollection),
226 GE(CLSID_DirectMusicCommandTrack),
227 GE(CLSID_DirectMusicComposer),
228 GE(CLSID_DirectMusicContainer),
229 GE(CLSID_DirectMusicGraph),
230 GE(CLSID_DirectMusicLoader),
231 GE(CLSID_DirectMusicLyricsTrack),
232 GE(CLSID_DirectMusicMarkerTrack),
233 GE(CLSID_DirectMusicMelodyFormulationTrack),
234 GE(CLSID_DirectMusicMotifTrack),
235 GE(CLSID_DirectMusicMuteTrack),
236 GE(CLSID_DirectMusicParamControlTrack),
237 GE(CLSID_DirectMusicPatternTrack),
238 GE(CLSID_DirectMusicPerformance),
239 GE(CLSID_DirectMusicScript),
240 GE(CLSID_DirectMusicScriptAutoImpSegment),
241 GE(CLSID_DirectMusicScriptAutoImpPerformance),
242 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
243 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
244 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
245 GE(CLSID_DirectMusicScriptAutoImpSong),
246 GE(CLSID_DirectMusicScriptSourceCodeLoader),
247 GE(CLSID_DirectMusicScriptTrack),
248 GE(CLSID_DirectMusicSection),
249 GE(CLSID_DirectMusicSegment),
250 GE(CLSID_DirectMusicSegmentState),
251 GE(CLSID_DirectMusicSegmentTriggerTrack),
252 GE(CLSID_DirectMusicSegTriggerTrack),
253 GE(CLSID_DirectMusicSeqTrack),
254 GE(CLSID_DirectMusicSignPostTrack),
255 GE(CLSID_DirectMusicSong),
256 GE(CLSID_DirectMusicStyle),
257 GE(CLSID_DirectMusicStyleTrack),
258 GE(CLSID_DirectMusicSynth),
259 GE(CLSID_DirectMusicSynthSink),
260 GE(CLSID_DirectMusicSysExTrack),
261 GE(CLSID_DirectMusicTemplate),
262 GE(CLSID_DirectMusicTempoTrack),
263 GE(CLSID_DirectMusicTimeSigTrack),
264 GE(CLSID_DirectMusicWaveTrack),
265 GE(CLSID_DirectSoundWave),
267 GE(IID_IDirectMusic),
268 GE(IID_IDirectMusic2),
269 GE(IID_IDirectMusic8),
270 GE(IID_IDirectMusicAudioPath),
271 GE(IID_IDirectMusicBand),
272 GE(IID_IDirectMusicBuffer),
273 GE(IID_IDirectMusicChordMap),
274 GE(IID_IDirectMusicCollection),
275 GE(IID_IDirectMusicComposer),
276 GE(IID_IDirectMusicContainer),
277 GE(IID_IDirectMusicDownload),
278 GE(IID_IDirectMusicDownloadedInstrument),
279 GE(IID_IDirectMusicGetLoader),
280 GE(IID_IDirectMusicGraph),
281 GE(IID_IDirectMusicInstrument),
282 GE(IID_IDirectMusicLoader),
283 GE(IID_IDirectMusicLoader8),
284 GE(IID_IDirectMusicObject),
285 GE(IID_IDirectMusicPatternTrack),
286 GE(IID_IDirectMusicPerformance),
287 GE(IID_IDirectMusicPerformance2),
288 GE(IID_IDirectMusicPerformance8),
289 GE(IID_IDirectMusicPort),
290 GE(IID_IDirectMusicPortDownload),
291 GE(IID_IDirectMusicScript),
292 GE(IID_IDirectMusicSegment),
293 GE(IID_IDirectMusicSegment2),
294 GE(IID_IDirectMusicSegment8),
295 GE(IID_IDirectMusicSegmentState),
296 GE(IID_IDirectMusicSegmentState8),
297 GE(IID_IDirectMusicStyle),
298 GE(IID_IDirectMusicStyle8),
299 GE(IID_IDirectMusicSynth),
300 GE(IID_IDirectMusicSynth8),
301 GE(IID_IDirectMusicSynthSink),
302 GE(IID_IDirectMusicThru),
303 GE(IID_IDirectMusicTool),
304 GE(IID_IDirectMusicTool8),
305 GE(IID_IDirectMusicTrack),
306 GE(IID_IDirectMusicTrack8),
308 GE(IID_IPersistStream),
310 GE(IID_IClassFactory),
312 GE(GUID_DirectMusicAllTypes),
313 GE(GUID_NOTIFICATION_CHORD),
314 GE(GUID_NOTIFICATION_COMMAND),
315 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
316 GE(GUID_NOTIFICATION_PERFORMANCE),
317 GE(GUID_NOTIFICATION_RECOMPOSE),
318 GE(GUID_NOTIFICATION_SEGMENT),
321 GE(GUID_CommandParam),
322 GE(GUID_CommandParam2),
323 GE(GUID_CommandParamNext),
324 GE(GUID_IDirectMusicBand),
325 GE(GUID_IDirectMusicChordMap),
326 GE(GUID_IDirectMusicStyle),
328 GE(GUID_Play_Marker),
329 GE(GUID_RhythmParam),
331 GE(GUID_TimeSignature),
332 GE(GUID_Valid_Start_Time),
333 GE(GUID_Clear_All_Bands),
334 GE(GUID_ConnectToDLSCollection),
335 GE(GUID_Disable_Auto_Download),
336 GE(GUID_DisableTempo),
337 GE(GUID_DisableTimeSig),
339 GE(GUID_DownloadToAudioPath),
340 GE(GUID_Enable_Auto_Download),
341 GE(GUID_EnableTempo),
342 GE(GUID_EnableTimeSig),
343 GE(GUID_IgnoreBankSelectForGM),
344 GE(GUID_SeedVariations),
345 GE(GUID_StandardMIDIFile),
347 GE(GUID_UnloadFromAudioPath),
349 GE(GUID_PerfMasterTempo),
350 GE(GUID_PerfMasterVolume),
351 GE(GUID_PerfMasterGrooveLevel),
352 GE(GUID_PerfAutoDownload),
353 GE(GUID_DefaultGMCollection),
354 GE(GUID_Synth_Default),
355 GE(GUID_Buffer_Reverb),
356 GE(GUID_Buffer_EnvReverb),
357 GE(GUID_Buffer_Stereo),
358 GE(GUID_Buffer_3D_Dry),
359 GE(GUID_Buffer_Mono),
360 GE(GUID_DMUS_PROP_GM_Hardware),
361 GE(GUID_DMUS_PROP_GS_Capable),
362 GE(GUID_DMUS_PROP_GS_Hardware),
363 GE(GUID_DMUS_PROP_DLS1),
364 GE(GUID_DMUS_PROP_DLS2),
365 GE(GUID_DMUS_PROP_Effects),
366 GE(GUID_DMUS_PROP_INSTRUMENT2),
367 GE(GUID_DMUS_PROP_LegacyCaps),
368 GE(GUID_DMUS_PROP_MemorySize),
369 GE(GUID_DMUS_PROP_SampleMemorySize),
370 GE(GUID_DMUS_PROP_SamplePlaybackRate),
371 GE(GUID_DMUS_PROP_SetSynthSink),
372 GE(GUID_DMUS_PROP_SinkUsesDSound),
373 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
374 GE(GUID_DMUS_PROP_SynthSink_WAVE),
375 GE(GUID_DMUS_PROP_Volume),
376 GE(GUID_DMUS_PROP_WavesReverb),
377 GE(GUID_DMUS_PROP_WriteLatency),
378 GE(GUID_DMUS_PROP_WritePeriod),
379 GE(GUID_DMUS_PROP_XG_Capable),
380 GE(GUID_DMUS_PROP_XG_Hardware)
385 if (!id) return "(null)";
387 for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
388 if (IsEqualGUID(id, &guids[i].guid))
389 return guids[i].name;
391 /* if we didn't find it, act like standard debugstr_guid */
392 return debugstr_guid(id);
395 /* returns name of given error code */
396 const char *debugstr_dmreturn (DWORD code) {
397 static const flag_info codes[] = {
400 FE(DMUS_S_PARTIALLOAD),
401 FE(DMUS_S_PARTIALDOWNLOAD),
405 FE(DMUS_S_STRING_TRUNCATED),
406 FE(DMUS_S_LAST_TOOL),
407 FE(DMUS_S_OVER_CHORD),
408 FE(DMUS_S_UP_OCTAVE),
409 FE(DMUS_S_DOWN_OCTAVE),
410 FE(DMUS_S_NOBUFFERCONTROL),
411 FE(DMUS_S_GARBAGE_COLLECTED),
412 FE(DMUS_E_DRIVER_FAILED),
413 FE(DMUS_E_PORTS_OPEN),
414 FE(DMUS_E_DEVICE_IN_USE),
415 FE(DMUS_E_INSUFFICIENTBUFFER),
416 FE(DMUS_E_BUFFERNOTSET),
417 FE(DMUS_E_BUFFERNOTAVAILABLE),
418 FE(DMUS_E_NOTADLSCOL),
419 FE(DMUS_E_INVALIDOFFSET),
420 FE(DMUS_E_ALREADY_LOADED),
421 FE(DMUS_E_INVALIDPOS),
422 FE(DMUS_E_INVALIDPATCH),
423 FE(DMUS_E_CANNOTSEEK),
424 FE(DMUS_E_CANNOTWRITE),
425 FE(DMUS_E_CHUNKNOTFOUND),
426 FE(DMUS_E_INVALID_DOWNLOADID),
427 FE(DMUS_E_NOT_DOWNLOADED_TO_PORT),
428 FE(DMUS_E_ALREADY_DOWNLOADED),
429 FE(DMUS_E_UNKNOWN_PROPERTY),
430 FE(DMUS_E_SET_UNSUPPORTED),
431 FE(DMUS_E_GET_UNSUPPORTED),
433 FE(DMUS_E_BADARTICULATION),
434 FE(DMUS_E_BADINSTRUMENT),
435 FE(DMUS_E_BADWAVELINK),
436 FE(DMUS_E_NOARTICULATION),
439 FE(DMUS_E_BADOFFSETTABLE),
440 FE(DMUS_E_UNKNOWNDOWNLOAD),
441 FE(DMUS_E_NOSYNTHSINK),
442 FE(DMUS_E_ALREADYOPEN),
443 FE(DMUS_E_ALREADYCLOSED),
444 FE(DMUS_E_SYNTHNOTCONFIGURED),
445 FE(DMUS_E_SYNTHACTIVE),
446 FE(DMUS_E_CANNOTREAD),
447 FE(DMUS_E_DMUSIC_RELEASED),
448 FE(DMUS_E_BUFFER_EMPTY),
449 FE(DMUS_E_BUFFER_FULL),
450 FE(DMUS_E_PORT_NOT_CAPTURE),
451 FE(DMUS_E_PORT_NOT_RENDER),
452 FE(DMUS_E_DSOUND_NOT_SET),
453 FE(DMUS_E_ALREADY_ACTIVATED),
454 FE(DMUS_E_INVALIDBUFFER),
455 FE(DMUS_E_WAVEFORMATNOTSUPPORTED),
456 FE(DMUS_E_SYNTHINACTIVE),
457 FE(DMUS_E_DSOUND_ALREADY_SET),
458 FE(DMUS_E_INVALID_EVENT),
459 FE(DMUS_E_UNSUPPORTED_STREAM),
460 FE(DMUS_E_ALREADY_INITED),
461 FE(DMUS_E_INVALID_BAND),
462 FE(DMUS_E_TRACK_HDR_NOT_FIRST_CK),
463 FE(DMUS_E_TOOL_HDR_NOT_FIRST_CK),
464 FE(DMUS_E_INVALID_TRACK_HDR),
465 FE(DMUS_E_INVALID_TOOL_HDR),
466 FE(DMUS_E_ALL_TOOLS_FAILED),
467 FE(DMUS_E_ALL_TRACKS_FAILED),
468 FE(DMUS_E_NOT_FOUND),
470 FE(DMUS_E_TYPE_DISABLED),
471 FE(DMUS_E_TYPE_UNSUPPORTED),
472 FE(DMUS_E_TIME_PAST),
473 FE(DMUS_E_TRACK_NOT_FOUND),
474 FE(DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT),
475 FE(DMUS_E_NO_MASTER_CLOCK),
476 FE(DMUS_E_LOADER_NOCLASSID),
477 FE(DMUS_E_LOADER_BADPATH),
478 FE(DMUS_E_LOADER_FAILEDOPEN),
479 FE(DMUS_E_LOADER_FORMATNOTSUPPORTED),
480 FE(DMUS_E_LOADER_FAILEDCREATE),
481 FE(DMUS_E_LOADER_OBJECTNOTFOUND),
482 FE(DMUS_E_LOADER_NOFILENAME),
483 FE(DMUS_E_INVALIDFILE),
484 FE(DMUS_E_ALREADY_EXISTS),
485 FE(DMUS_E_OUT_OF_RANGE),
486 FE(DMUS_E_SEGMENT_INIT_FAILED),
487 FE(DMUS_E_ALREADY_SENT),
488 FE(DMUS_E_CANNOT_FREE),
489 FE(DMUS_E_CANNOT_OPEN_PORT),
490 FE(DMUS_E_CANNOT_CONVERT),
491 FE(DMUS_E_DESCEND_CHUNK_FAIL),
492 FE(DMUS_E_NOT_LOADED),
493 FE(DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE),
494 FE(DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE),
495 FE(DMUS_E_SCRIPT_ERROR_IN_SCRIPT),
496 FE(DMUS_E_SCRIPT_CANTLOAD_OLEAUT32),
497 FE(DMUS_E_SCRIPT_LOADSCRIPT_ERROR),
498 FE(DMUS_E_SCRIPT_INVALID_FILE),
499 FE(DMUS_E_INVALID_SCRIPTTRACK),
500 FE(DMUS_E_SCRIPT_VARIABLE_NOT_FOUND),
501 FE(DMUS_E_SCRIPT_ROUTINE_NOT_FOUND),
502 FE(DMUS_E_SCRIPT_CONTENT_READONLY),
503 FE(DMUS_E_SCRIPT_NOT_A_REFERENCE),
504 FE(DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED),
505 FE(DMUS_E_INVALID_SEGMENTTRIGGERTRACK),
506 FE(DMUS_E_INVALID_LYRICSTRACK),
507 FE(DMUS_E_INVALID_PARAMCONTROLTRACK),
508 FE(DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR),
509 FE(DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR),
510 FE(DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE),
511 FE(DMUS_E_AUDIOPATHS_NOT_VALID),
512 FE(DMUS_E_AUDIOPATHS_IN_USE),
513 FE(DMUS_E_NO_AUDIOPATH_CONFIG),
514 FE(DMUS_E_AUDIOPATH_INACTIVE),
515 FE(DMUS_E_AUDIOPATH_NOBUFFER),
516 FE(DMUS_E_AUDIOPATH_NOPORT),
517 FE(DMUS_E_NO_AUDIOPATH),
518 FE(DMUS_E_INVALIDCHUNK),
519 FE(DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER),
520 FE(DMUS_E_INVALID_CONTAINER_OBJECT)
523 for (i = 0; i < sizeof(codes)/sizeof(codes[0]); i++) {
524 if (code == codes[i].val)
525 return codes[i].name;
527 /* if we didn't find it, return value */
528 return wine_dbg_sprintf("0x%08lx", code);
531 /* generic flag-dumping function */
532 const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
533 char buffer[128] = "", *ptr = &buffer[0];
534 unsigned int i, size = sizeof(buffer);
536 for (i=0; i < num_names; i++)
538 if ((flags & names[i].val) || /* standard flag*/
539 ((!flags) && (!names[i].val))) { /* zero value only */
540 int cnt = snprintf(ptr, size, "%s ", names[i].name);
541 if (cnt < 0 || cnt >= size) break;
547 return wine_dbg_sprintf("%s", buffer);
550 /* dump DMUS_OBJ flags */
551 const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
552 static const flag_info flags[] = {
556 FE(DMUS_OBJ_CATEGORY),
557 FE(DMUS_OBJ_FILENAME),
558 FE(DMUS_OBJ_FULLPATH),
560 FE(DMUS_OBJ_VERSION),
566 return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
569 /* dump whole DMUS_OBJECTDESC struct */
570 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
572 char buffer[1024] = "", *ptr = &buffer[0];
574 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
575 ptr += sprintf(ptr, " - dwSize = %ld\n", pDesc->dwSize);
576 ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
577 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
578 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
579 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
580 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
581 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
582 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
583 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
584 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = %lli\n - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData);
585 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
587 return wine_dbg_sprintf("%s", buffer);
589 return wine_dbg_sprintf("(NULL)");