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