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