- Add the same new files (dmutils.c/dmutils.h) into dmime,dmband and
[wine.git] / dlls / dmime / dmutils.c
blob3da649d3a05a32e4976c79714c8d176345c19da8
1 /* Debug and Helper Functions
3 * Copyright (C) 2004 Rok Mandeljc
4 * Copyright (C) 2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <string.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnt.h"
28 #include "wingdi.h"
29 #include "winuser.h"
31 #include "wine/debug.h"
32 #include "wine/list.h"
33 #include "wine/unicode.h"
34 #include "winreg.h"
36 #include "dmusici.h"
37 #include "dmusicf.h"
38 #include "dmusics.h"
40 #include "dmutils.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
43 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
45 /* check whether the given DWORD is even (return 0) or odd (return 1) */
46 int even_or_odd (DWORD number) {
47 return (number & 0x1); /* basically, check if bit 0 is set ;) */
50 /* figures out whether given FOURCC is valid DirectMusic form ID */
51 BOOL IS_VALID_DMFORM (FOURCC chunkID) {
52 if ((chunkID == DMUS_FOURCC_AUDIOPATH_FORM) || (chunkID == DMUS_FOURCC_BAND_FORM) || (chunkID == DMUS_FOURCC_CHORDMAP_FORM)
53 || (chunkID == DMUS_FOURCC_CONTAINER_FORM) || (chunkID == FOURCC_DLS) || (chunkID == DMUS_FOURCC_SCRIPT_FORM)
54 || (chunkID == DMUS_FOURCC_SEGMENT_FORM) || (chunkID == DMUS_FOURCC_STYLE_FORM) || (chunkID == DMUS_FOURCC_TOOLGRAPH_FORM)
55 || (chunkID == DMUS_FOURCC_TRACK_FORM) || (chunkID == mmioFOURCC('W','A','V','E'))) return TRUE;
56 else return FALSE;
59 HRESULT IDirectMusicUtils_IPersistStream_ParseDescGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc) {
61 switch (pChunk->fccID) {
62 case DMUS_FOURCC_GUID_CHUNK: {
63 TRACE_(dmfile)(": GUID chunk\n");
64 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
65 IStream_Read (pStm, &pDesc->guidObject, pChunk->dwSize, NULL);
66 break;
68 case DMUS_FOURCC_DATE_CHUNK: {
69 TRACE_(dmfile)(": file date chunk\n");
70 pDesc->dwValidData |= DMUS_OBJ_DATE;
71 IStream_Read (pStm, &pDesc->ftDate, pChunk->dwSize, NULL);
72 break;
74 case DMUS_FOURCC_NAME_CHUNK: {
75 TRACE_(dmfile)(": name chunk\n");
76 pDesc->dwValidData |= DMUS_OBJ_NAME;
77 IStream_Read (pStm, &pDesc->wszName, pChunk->dwSize, NULL);
78 break;
80 case DMUS_FOURCC_FILE_CHUNK: {
81 TRACE_(dmfile)(": file name chunk\n");
82 pDesc->dwValidData |= DMUS_OBJ_FILENAME;
83 IStream_Read (pStm, &pDesc->wszFileName, pChunk->dwSize, NULL);
84 break;
86 case DMUS_FOURCC_VERSION_CHUNK: {
87 TRACE_(dmfile)(": version chunk\n");
88 pDesc->dwValidData |= DMUS_OBJ_VERSION;
89 IStream_Read (pStm, &pDesc->vVersion, pChunk->dwSize, NULL);
90 break;
92 case DMUS_FOURCC_CATEGORY_CHUNK: {
93 TRACE_(dmfile)(": category chunk\n");
94 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
95 IStream_Read (pStm, pDesc->wszCategory, pChunk->dwSize, NULL);
96 break;
98 default:
99 /* not handled */
100 return S_FALSE;
103 return S_OK;
106 HRESULT IDirectMusicUtils_IPersistStream_ParseUNFOGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc) {
108 LARGE_INTEGER liMove; /* used when skipping chunks */
111 * don't ask me why, but M$ puts INFO elements in UNFO list sometimes
112 * (though strings seem to be valid unicode)
114 switch (pChunk->fccID) {
116 case mmioFOURCC('I','N','A','M'):
117 case DMUS_FOURCC_UNAM_CHUNK: {
118 TRACE_(dmfile)(": name chunk\n");
119 pDesc->dwValidData |= DMUS_OBJ_NAME;
120 IStream_Read (pStm, pDesc->wszName, pChunk->dwSize, NULL);
121 TRACE_(dmfile)(" - wszName: %s\n", debugstr_w(pDesc->wszName));
122 break;
125 case mmioFOURCC('I','A','R','T'):
126 case DMUS_FOURCC_UART_CHUNK: {
127 TRACE_(dmfile)(": artist chunk (ignored)\n");
128 liMove.QuadPart = pChunk->dwSize;
129 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
130 break;
132 case mmioFOURCC('I','C','O','P'):
133 case DMUS_FOURCC_UCOP_CHUNK: {
134 TRACE_(dmfile)(": copyright chunk (ignored)\n");
135 liMove.QuadPart = pChunk->dwSize;
136 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
137 break;
139 case mmioFOURCC('I','S','B','J'):
140 case DMUS_FOURCC_USBJ_CHUNK: {
141 TRACE_(dmfile)(": subject chunk (ignored)\n");
142 liMove.QuadPart = pChunk->dwSize;
143 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
144 break;
146 case mmioFOURCC('I','C','M','T'):
147 case DMUS_FOURCC_UCMT_CHUNK: {
148 TRACE_(dmfile)(": comment chunk (ignored)\n");
149 liMove.QuadPart = pChunk->dwSize;
150 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
151 break;
153 default:
154 /* not handled */
155 return S_FALSE;
158 return S_OK;
161 HRESULT IDirectMusicUtils_IPersistStream_ParseReference (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, IDirectMusicObject** ppObject) {
162 DMUS_PRIVATE_CHUNK Chunk;
163 DWORD ListSize[3], ListCount[3];
164 LARGE_INTEGER liMove; /* used when skipping chunks */
165 HRESULT hr;
167 DMUS_IO_REFERENCE ref;
168 DMUS_OBJECTDESC ref_desc;
170 memset(&ref, 0, sizeof(ref));
171 memset(&ref_desc, 0, sizeof(ref_desc));
173 if (pChunk->fccID != DMUS_FOURCC_REF_LIST) {
174 ERR_(dmfile)(": %s chunk should be a REF list\n", debugstr_fourcc (pChunk->fccID));
175 return E_FAIL;
178 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
179 ListCount[0] = 0;
181 do {
182 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
183 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
184 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
186 hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, &ref_desc);
187 if (FAILED(hr)) return hr;
189 if (hr == S_FALSE) {
190 switch (Chunk.fccID) {
191 case DMUS_FOURCC_REF_CHUNK: {
192 TRACE_(dmfile)(": Reference chunk\n");
193 if (Chunk.dwSize != sizeof(DMUS_IO_REFERENCE)) return E_FAIL;
194 IStream_Read (pStm, &ref, sizeof(DMUS_IO_REFERENCE), NULL);
195 TRACE_(dmfile)(" - guidClassID: %s\n", debugstr_dmguid(&ref.guidClassID));
196 TRACE_(dmfile)(" - dwValidData: %lu\n", ref.dwValidData);
197 break;
199 default: {
200 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
201 liMove.QuadPart = Chunk.dwSize;
202 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
203 break;
207 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
208 } while (ListCount[0] < ListSize[0]);
210 ref_desc.dwValidData |= DMUS_OBJ_CLASS;
211 memcpy(&ref_desc.guidClass, &ref.guidClassID, sizeof(ref.guidClassID));
213 TRACE_(dmfile)("** DM Reference Begin of Load ***\n");
214 TRACE_(dmfile)("With Desc:\n");
215 debugstr_DMUS_OBJECTDESC(&ref_desc);
218 LPDIRECTMUSICGETLOADER pGetLoader = NULL;
219 LPDIRECTMUSICLOADER pLoader = NULL;
221 IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader);
222 IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader);
223 IDirectMusicGetLoader_Release (pGetLoader);
225 hr = IDirectMusicLoader_GetObject (pLoader, &ref_desc, &IID_IDirectMusicObject, (LPVOID*)ppObject);
226 IDirectMusicLoader_Release (pLoader); /* release loader */
228 TRACE_(dmfile)("** DM Reference End of Load ***\n");
230 return S_OK;
233 /* translate STREAM_SEEK flag to string */
234 const char *resolve_STREAM_SEEK (DWORD flag) {
235 switch (flag) {
236 case STREAM_SEEK_SET:
237 return wine_dbg_sprintf ("STREAM_SEEK_SET");
238 case STREAM_SEEK_CUR:
239 return wine_dbg_sprintf ("STREAM_SEEK_CUR");
240 case STREAM_SEEK_END:
241 return wine_dbg_sprintf ("STREAM_SEEK_END");
242 default:
243 return wine_dbg_sprintf ("()");
247 /* FOURCC to string conversion for debug messages */
248 const char *debugstr_fourcc (DWORD fourcc) {
249 if (!fourcc) return "'null'";
250 return wine_dbg_sprintf ("\'%c%c%c%c\'",
251 (char)(fourcc), (char)(fourcc >> 8),
252 (char)(fourcc >> 16), (char)(fourcc >> 24));
255 /* DMUS_VERSION struct to string conversion for debug messages */
256 const char *debugstr_dmversion (LPDMUS_VERSION version) {
257 if (!version) return "'null'";
258 return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
259 HIWORD(version->dwVersionMS),LOWORD(version->dwVersionMS),
260 HIWORD(version->dwVersionLS), LOWORD(version->dwVersionLS));
263 /* month number into month name (for debugstr_filetime) */
264 const char *debugstr_month (DWORD dwMonth) {
265 switch (dwMonth) {
266 case 1: return "January";
267 case 2: return "February";
268 case 3: return "March";
269 case 4: return "April";
270 case 5: return "May";
271 case 6: return "June";
272 case 7: return "July";
273 case 8: return "August";
274 case 9: return "September";
275 case 10: return "October";
276 case 11: return "November";
277 case 12: return "December";
278 default: return "Invalid";
282 /* FILETIME struct to string conversion for debug messages */
283 const char *debugstr_filetime (LPFILETIME time) {
284 SYSTEMTIME sysTime;
286 if (!time) return "'null'";
288 FileTimeToSystemTime (time, &sysTime);
290 return wine_dbg_sprintf ("\'%02i. %s %04i %02i:%02i:%02i\'", \
291 sysTime.wDay, debugstr_month(sysTime.wMonth), sysTime.wYear,
292 sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
295 /* returns name of given GUID */
296 const char *debugstr_dmguid (const GUID *id) {
297 static const guid_info guids[] = {
298 /* CLSIDs */
299 GE(CLSID_AudioVBScript),
300 GE(CLSID_DirectMusic),
301 GE(CLSID_DirectMusicAudioPath),
302 GE(CLSID_DirectMusicAudioPathConfig),
303 GE(CLSID_DirectMusicAuditionTrack),
304 GE(CLSID_DirectMusicBand),
305 GE(CLSID_DirectMusicBandTrack),
306 GE(CLSID_DirectMusicChordMapTrack),
307 GE(CLSID_DirectMusicChordMap),
308 GE(CLSID_DirectMusicChordTrack),
309 GE(CLSID_DirectMusicCollection),
310 GE(CLSID_DirectMusicCommandTrack),
311 GE(CLSID_DirectMusicComposer),
312 GE(CLSID_DirectMusicContainer),
313 GE(CLSID_DirectMusicGraph),
314 GE(CLSID_DirectMusicLoader),
315 GE(CLSID_DirectMusicLyricsTrack),
316 GE(CLSID_DirectMusicMarkerTrack),
317 GE(CLSID_DirectMusicMelodyFormulationTrack),
318 GE(CLSID_DirectMusicMotifTrack),
319 GE(CLSID_DirectMusicMuteTrack),
320 GE(CLSID_DirectMusicParamControlTrack),
321 GE(CLSID_DirectMusicPatternTrack),
322 GE(CLSID_DirectMusicPerformance),
323 GE(CLSID_DirectMusicScript),
324 GE(CLSID_DirectMusicScriptAutoImpSegment),
325 GE(CLSID_DirectMusicScriptAutoImpPerformance),
326 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
327 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
328 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
329 GE(CLSID_DirectMusicScriptAutoImpSong),
330 GE(CLSID_DirectMusicScriptSourceCodeLoader),
331 GE(CLSID_DirectMusicScriptTrack),
332 GE(CLSID_DirectMusicSection),
333 GE(CLSID_DirectMusicSegment),
334 GE(CLSID_DirectMusicSegmentState),
335 GE(CLSID_DirectMusicSegmentTriggerTrack),
336 GE(CLSID_DirectMusicSegTriggerTrack),
337 GE(CLSID_DirectMusicSeqTrack),
338 GE(CLSID_DirectMusicSignPostTrack),
339 GE(CLSID_DirectMusicSong),
340 GE(CLSID_DirectMusicStyle),
341 GE(CLSID_DirectMusicStyleTrack),
342 GE(CLSID_DirectMusicSynth),
343 GE(CLSID_DirectMusicSynthSink),
344 GE(CLSID_DirectMusicSysExTrack),
345 GE(CLSID_DirectMusicTemplate),
346 GE(CLSID_DirectMusicTempoTrack),
347 GE(CLSID_DirectMusicTimeSigTrack),
348 GE(CLSID_DirectMusicWaveTrack),
349 GE(CLSID_DirectSoundWave),
350 /* IIDs */
351 GE(IID_IDirectMusic),
352 GE(IID_IDirectMusic2),
353 GE(IID_IDirectMusic8),
354 GE(IID_IDirectMusicAudioPath),
355 GE(IID_IDirectMusicBand),
356 GE(IID_IDirectMusicBuffer),
357 GE(IID_IDirectMusicChordMap),
358 GE(IID_IDirectMusicCollection),
359 GE(IID_IDirectMusicComposer),
360 GE(IID_IDirectMusicContainer),
361 GE(IID_IDirectMusicDownload),
362 GE(IID_IDirectMusicDownloadedInstrument),
363 GE(IID_IDirectMusicGetLoader),
364 GE(IID_IDirectMusicGraph),
365 GE(IID_IDirectMusicInstrument),
366 GE(IID_IDirectMusicLoader),
367 GE(IID_IDirectMusicLoader8),
368 GE(IID_IDirectMusicObject),
369 GE(IID_IDirectMusicPatternTrack),
370 GE(IID_IDirectMusicPerformance),
371 GE(IID_IDirectMusicPerformance2),
372 GE(IID_IDirectMusicPerformance8),
373 GE(IID_IDirectMusicPort),
374 GE(IID_IDirectMusicPortDownload),
375 GE(IID_IDirectMusicScript),
376 GE(IID_IDirectMusicSegment),
377 GE(IID_IDirectMusicSegment2),
378 GE(IID_IDirectMusicSegment8),
379 GE(IID_IDirectMusicSegmentState),
380 GE(IID_IDirectMusicSegmentState8),
381 GE(IID_IDirectMusicStyle),
382 GE(IID_IDirectMusicStyle8),
383 GE(IID_IDirectMusicSynth),
384 GE(IID_IDirectMusicSynth8),
385 GE(IID_IDirectMusicSynthSink),
386 GE(IID_IDirectMusicThru),
387 GE(IID_IDirectMusicTool),
388 GE(IID_IDirectMusicTool8),
389 GE(IID_IDirectMusicTrack),
390 GE(IID_IDirectMusicTrack8),
391 GE(IID_IUnknown),
392 GE(IID_IPersistStream),
393 GE(IID_IStream),
394 GE(IID_IClassFactory),
395 /* GUIDs */
396 GE(GUID_DirectMusicAllTypes),
397 GE(GUID_NOTIFICATION_CHORD),
398 GE(GUID_NOTIFICATION_COMMAND),
399 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
400 GE(GUID_NOTIFICATION_PERFORMANCE),
401 GE(GUID_NOTIFICATION_RECOMPOSE),
402 GE(GUID_NOTIFICATION_SEGMENT),
403 GE(GUID_BandParam),
404 GE(GUID_ChordParam),
405 GE(GUID_CommandParam),
406 GE(GUID_CommandParam2),
407 GE(GUID_CommandParamNext),
408 GE(GUID_IDirectMusicBand),
409 GE(GUID_IDirectMusicChordMap),
410 GE(GUID_IDirectMusicStyle),
411 GE(GUID_MuteParam),
412 GE(GUID_Play_Marker),
413 GE(GUID_RhythmParam),
414 GE(GUID_TempoParam),
415 GE(GUID_TimeSignature),
416 GE(GUID_Valid_Start_Time),
417 GE(GUID_Clear_All_Bands),
418 GE(GUID_ConnectToDLSCollection),
419 GE(GUID_Disable_Auto_Download),
420 GE(GUID_DisableTempo),
421 GE(GUID_DisableTimeSig),
422 GE(GUID_Download),
423 GE(GUID_DownloadToAudioPath),
424 GE(GUID_Enable_Auto_Download),
425 GE(GUID_EnableTempo),
426 GE(GUID_EnableTimeSig),
427 GE(GUID_IgnoreBankSelectForGM),
428 GE(GUID_SeedVariations),
429 GE(GUID_StandardMIDIFile),
430 GE(GUID_Unload),
431 GE(GUID_UnloadFromAudioPath),
432 GE(GUID_Variations),
433 GE(GUID_PerfMasterTempo),
434 GE(GUID_PerfMasterVolume),
435 GE(GUID_PerfMasterGrooveLevel),
436 GE(GUID_PerfAutoDownload),
437 GE(GUID_DefaultGMCollection),
438 GE(GUID_Synth_Default),
439 GE(GUID_Buffer_Reverb),
440 GE(GUID_Buffer_EnvReverb),
441 GE(GUID_Buffer_Stereo),
442 GE(GUID_Buffer_3D_Dry),
443 GE(GUID_Buffer_Mono),
444 GE(GUID_DMUS_PROP_GM_Hardware),
445 GE(GUID_DMUS_PROP_GS_Capable),
446 GE(GUID_DMUS_PROP_GS_Hardware),
447 GE(GUID_DMUS_PROP_DLS1),
448 GE(GUID_DMUS_PROP_DLS2),
449 GE(GUID_DMUS_PROP_Effects),
450 GE(GUID_DMUS_PROP_INSTRUMENT2),
451 GE(GUID_DMUS_PROP_LegacyCaps),
452 GE(GUID_DMUS_PROP_MemorySize),
453 GE(GUID_DMUS_PROP_SampleMemorySize),
454 GE(GUID_DMUS_PROP_SamplePlaybackRate),
455 GE(GUID_DMUS_PROP_SetSynthSink),
456 GE(GUID_DMUS_PROP_SinkUsesDSound),
457 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
458 GE(GUID_DMUS_PROP_SynthSink_WAVE),
459 GE(GUID_DMUS_PROP_Volume),
460 GE(GUID_DMUS_PROP_WavesReverb),
461 GE(GUID_DMUS_PROP_WriteLatency),
462 GE(GUID_DMUS_PROP_WritePeriod),
463 GE(GUID_DMUS_PROP_XG_Capable),
464 GE(GUID_DMUS_PROP_XG_Hardware)
467 unsigned int i;
469 if (!id) return "(null)";
470 for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
471 if (IsEqualGUID(id, guids[i].guid))
472 return guids[i].name;
475 /* if we didn't find it, act like standard debugstr_guid */
476 return debugstr_guid(id);
479 /* returns name of given error code */
480 const char *debugstr_dmreturn (DWORD code) {
481 static const flag_info codes[] = {
482 FE(S_OK),
483 FE(S_FALSE),
484 FE(DMUS_S_PARTIALLOAD),
485 FE(DMUS_S_PARTIALDOWNLOAD),
486 FE(DMUS_S_REQUEUE),
487 FE(DMUS_S_FREE),
488 FE(DMUS_S_END),
489 FE(DMUS_S_STRING_TRUNCATED),
490 FE(DMUS_S_LAST_TOOL),
491 FE(DMUS_S_OVER_CHORD),
492 FE(DMUS_S_UP_OCTAVE),
493 FE(DMUS_S_DOWN_OCTAVE),
494 FE(DMUS_S_NOBUFFERCONTROL),
495 FE(DMUS_S_GARBAGE_COLLECTED),
496 FE(E_NOTIMPL),
497 FE(E_NOINTERFACE),
498 FE(E_POINTER),
499 FE(CLASS_E_NOAGGREGATION),
500 FE(CLASS_E_CLASSNOTAVAILABLE),
501 FE(REGDB_E_CLASSNOTREG),
502 FE(E_OUTOFMEMORY),
503 FE(E_FAIL),
504 FE(E_INVALIDARG),
505 FE(DMUS_E_DRIVER_FAILED),
506 FE(DMUS_E_PORTS_OPEN),
507 FE(DMUS_E_DEVICE_IN_USE),
508 FE(DMUS_E_INSUFFICIENTBUFFER),
509 FE(DMUS_E_BUFFERNOTSET),
510 FE(DMUS_E_BUFFERNOTAVAILABLE),
511 FE(DMUS_E_NOTADLSCOL),
512 FE(DMUS_E_INVALIDOFFSET),
513 FE(DMUS_E_ALREADY_LOADED),
514 FE(DMUS_E_INVALIDPOS),
515 FE(DMUS_E_INVALIDPATCH),
516 FE(DMUS_E_CANNOTSEEK),
517 FE(DMUS_E_CANNOTWRITE),
518 FE(DMUS_E_CHUNKNOTFOUND),
519 FE(DMUS_E_INVALID_DOWNLOADID),
520 FE(DMUS_E_NOT_DOWNLOADED_TO_PORT),
521 FE(DMUS_E_ALREADY_DOWNLOADED),
522 FE(DMUS_E_UNKNOWN_PROPERTY),
523 FE(DMUS_E_SET_UNSUPPORTED),
524 FE(DMUS_E_GET_UNSUPPORTED),
525 FE(DMUS_E_NOTMONO),
526 FE(DMUS_E_BADARTICULATION),
527 FE(DMUS_E_BADINSTRUMENT),
528 FE(DMUS_E_BADWAVELINK),
529 FE(DMUS_E_NOARTICULATION),
530 FE(DMUS_E_NOTPCM),
531 FE(DMUS_E_BADWAVE),
532 FE(DMUS_E_BADOFFSETTABLE),
533 FE(DMUS_E_UNKNOWNDOWNLOAD),
534 FE(DMUS_E_NOSYNTHSINK),
535 FE(DMUS_E_ALREADYOPEN),
536 FE(DMUS_E_ALREADYCLOSED),
537 FE(DMUS_E_SYNTHNOTCONFIGURED),
538 FE(DMUS_E_SYNTHACTIVE),
539 FE(DMUS_E_CANNOTREAD),
540 FE(DMUS_E_DMUSIC_RELEASED),
541 FE(DMUS_E_BUFFER_EMPTY),
542 FE(DMUS_E_BUFFER_FULL),
543 FE(DMUS_E_PORT_NOT_CAPTURE),
544 FE(DMUS_E_PORT_NOT_RENDER),
545 FE(DMUS_E_DSOUND_NOT_SET),
546 FE(DMUS_E_ALREADY_ACTIVATED),
547 FE(DMUS_E_INVALIDBUFFER),
548 FE(DMUS_E_WAVEFORMATNOTSUPPORTED),
549 FE(DMUS_E_SYNTHINACTIVE),
550 FE(DMUS_E_DSOUND_ALREADY_SET),
551 FE(DMUS_E_INVALID_EVENT),
552 FE(DMUS_E_UNSUPPORTED_STREAM),
553 FE(DMUS_E_ALREADY_INITED),
554 FE(DMUS_E_INVALID_BAND),
555 FE(DMUS_E_TRACK_HDR_NOT_FIRST_CK),
556 FE(DMUS_E_TOOL_HDR_NOT_FIRST_CK),
557 FE(DMUS_E_INVALID_TRACK_HDR),
558 FE(DMUS_E_INVALID_TOOL_HDR),
559 FE(DMUS_E_ALL_TOOLS_FAILED),
560 FE(DMUS_E_ALL_TRACKS_FAILED),
561 FE(DMUS_E_NOT_FOUND),
562 FE(DMUS_E_NOT_INIT),
563 FE(DMUS_E_TYPE_DISABLED),
564 FE(DMUS_E_TYPE_UNSUPPORTED),
565 FE(DMUS_E_TIME_PAST),
566 FE(DMUS_E_TRACK_NOT_FOUND),
567 FE(DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT),
568 FE(DMUS_E_NO_MASTER_CLOCK),
569 FE(DMUS_E_LOADER_NOCLASSID),
570 FE(DMUS_E_LOADER_BADPATH),
571 FE(DMUS_E_LOADER_FAILEDOPEN),
572 FE(DMUS_E_LOADER_FORMATNOTSUPPORTED),
573 FE(DMUS_E_LOADER_FAILEDCREATE),
574 FE(DMUS_E_LOADER_OBJECTNOTFOUND),
575 FE(DMUS_E_LOADER_NOFILENAME),
576 FE(DMUS_E_INVALIDFILE),
577 FE(DMUS_E_ALREADY_EXISTS),
578 FE(DMUS_E_OUT_OF_RANGE),
579 FE(DMUS_E_SEGMENT_INIT_FAILED),
580 FE(DMUS_E_ALREADY_SENT),
581 FE(DMUS_E_CANNOT_FREE),
582 FE(DMUS_E_CANNOT_OPEN_PORT),
583 FE(DMUS_E_CANNOT_CONVERT),
584 FE(DMUS_E_DESCEND_CHUNK_FAIL),
585 FE(DMUS_E_NOT_LOADED),
586 FE(DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE),
587 FE(DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE),
588 FE(DMUS_E_SCRIPT_ERROR_IN_SCRIPT),
589 FE(DMUS_E_SCRIPT_CANTLOAD_OLEAUT32),
590 FE(DMUS_E_SCRIPT_LOADSCRIPT_ERROR),
591 FE(DMUS_E_SCRIPT_INVALID_FILE),
592 FE(DMUS_E_INVALID_SCRIPTTRACK),
593 FE(DMUS_E_SCRIPT_VARIABLE_NOT_FOUND),
594 FE(DMUS_E_SCRIPT_ROUTINE_NOT_FOUND),
595 FE(DMUS_E_SCRIPT_CONTENT_READONLY),
596 FE(DMUS_E_SCRIPT_NOT_A_REFERENCE),
597 FE(DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED),
598 FE(DMUS_E_INVALID_SEGMENTTRIGGERTRACK),
599 FE(DMUS_E_INVALID_LYRICSTRACK),
600 FE(DMUS_E_INVALID_PARAMCONTROLTRACK),
601 FE(DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR),
602 FE(DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR),
603 FE(DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE),
604 FE(DMUS_E_AUDIOPATHS_NOT_VALID),
605 FE(DMUS_E_AUDIOPATHS_IN_USE),
606 FE(DMUS_E_NO_AUDIOPATH_CONFIG),
607 FE(DMUS_E_AUDIOPATH_INACTIVE),
608 FE(DMUS_E_AUDIOPATH_NOBUFFER),
609 FE(DMUS_E_AUDIOPATH_NOPORT),
610 FE(DMUS_E_NO_AUDIOPATH),
611 FE(DMUS_E_INVALIDCHUNK),
612 FE(DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER),
613 FE(DMUS_E_INVALID_CONTAINER_OBJECT)
616 unsigned int i;
617 for (i = 0; i < sizeof(codes)/sizeof(codes[0]); i++) {
618 if (code == codes[i].val)
619 return codes[i].name;
622 /* if we didn't find it, return value */
623 return wine_dbg_sprintf("0x%08lX", code);
627 /* generic flag-dumping function */
628 const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
629 static char buffer[128] = "", *ptr = &buffer[0];
630 unsigned int i, size = sizeof(buffer);
632 for (i=0; i < num_names; i++) {
633 if ((flags & names[i].val)) {
634 int cnt = snprintf(ptr, size, "%s ", names[i].name);
635 if (cnt < 0 || cnt >= size) break;
636 size -= cnt;
637 ptr += cnt;
641 ptr = &buffer[0];
642 return ptr;
645 /* dump DMUS_OBJ flags */
646 const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
647 static const flag_info flags[] = {
648 FE(DMUS_OBJ_OBJECT),
649 FE(DMUS_OBJ_CLASS),
650 FE(DMUS_OBJ_NAME),
651 FE(DMUS_OBJ_CATEGORY),
652 FE(DMUS_OBJ_FILENAME),
653 FE(DMUS_OBJ_FULLPATH),
654 FE(DMUS_OBJ_URL),
655 FE(DMUS_OBJ_VERSION),
656 FE(DMUS_OBJ_DATE),
657 FE(DMUS_OBJ_LOADED),
658 FE(DMUS_OBJ_MEMORY),
659 FE(DMUS_OBJ_STREAM)
661 return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
664 /* dump DMUS_CONTAINER flags */
665 const char *debugstr_DMUS_CONTAINER_FLAGS (DWORD flagmask) {
666 static const flag_info flags[] = {
667 FE(DMUS_CONTAINER_NOLOADS)
669 return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
672 /* dump DMUS_CONTAINED_OBJF flags */
673 const char *debugstr_DMUS_CONTAINED_OBJF_FLAGS (DWORD flagmask) {
674 static const flag_info flags[] = {
675 FE(DMUS_CONTAINED_OBJF_KEEP)
677 return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
680 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
681 if (pDesc) {
682 char buffer[1024] = "", *ptr = &buffer[0];
684 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
685 ptr += sprintf(ptr, " - dwSize = 0x%08lX\n", pDesc->dwSize);
686 ptr += sprintf(ptr, " - dwValidData = 0x%08lX ( %s)\n", pDesc->dwValidData, debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
687 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
688 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
689 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = %s\n", debugstr_filetime (&pDesc->ftDate));
690 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
691 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
692 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
693 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
694 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = %lli\n - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData);
695 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p\n", pDesc->pStream);
697 ptr = &buffer[0];
698 return ptr;
699 } else {
700 return wine_dbg_sprintf("(NULL)");
704 void debug_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
705 if (pDesc) {
706 TRACE("DMUS_OBJECTDESC (%p):\n", pDesc);
707 TRACE(" - dwSize = %ld\n", pDesc->dwSize);
708 TRACE(" - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
709 if (pDesc->dwValidData & DMUS_OBJ_NAME) TRACE(" - wszName = %s\n", debugstr_w(pDesc->wszName));
710 if (pDesc->dwValidData & DMUS_OBJ_CLASS) TRACE(" - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
711 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
712 if (pDesc->dwValidData & DMUS_OBJ_DATE) TRACE(" - ftDate = FIXME\n");
713 if (pDesc->dwValidData & DMUS_OBJ_VERSION) TRACE(" - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
714 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) TRACE(" - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
715 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) TRACE(" - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
716 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) TRACE(" - llMemLength = %lli\n - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData);
717 if (pDesc->dwValidData & DMUS_OBJ_STREAM) TRACE(" - pStream = %p\n", pDesc->pStream);
718 } else {
719 TRACE("(NULL)\n");
723 const char *debugstr_DMUS_IO_CONTAINER_HEADER (LPDMUS_IO_CONTAINER_HEADER pHeader) {
724 if (pHeader) {
725 char buffer[1024] = "", *ptr = &buffer[0];
727 ptr += sprintf(ptr, "DMUS_IO_CONTAINER_HEADER (%p):\n", pHeader);
728 ptr += sprintf(ptr, " - dwFlags = %s\n", debugstr_DMUS_CONTAINER_FLAGS(pHeader->dwFlags));
730 ptr = &buffer[0];
731 return ptr;
732 } else {
733 return wine_dbg_sprintf("(NULL)");
737 const char *debugstr_DMUS_IO_CONTAINED_OBJECT_HEADER (LPDMUS_IO_CONTAINED_OBJECT_HEADER pHeader) {
738 if (pHeader) {
739 char buffer[1024] = "", *ptr = &buffer[0];
741 ptr += sprintf(ptr, "DMUS_IO_CONTAINED_OBJECT_HEADER (%p):\n", pHeader);
742 ptr += sprintf(ptr, " - guidClassID = %s\n", debugstr_dmguid(&pHeader->guidClassID));
743 ptr += sprintf(ptr, " - dwFlags = %s\n", debugstr_DMUS_CONTAINED_OBJF_FLAGS (pHeader->dwFlags));
744 ptr += sprintf(ptr, " - ckid = %s\n", debugstr_fourcc (pHeader->ckid));
745 ptr += sprintf(ptr, " - fccType = %s\n", debugstr_fourcc (pHeader->fccType));
747 ptr = &buffer[0];
748 return ptr;
749 } else {
750 return wine_dbg_sprintf("(NULL)");