- Generate machine-local IPIDs.
[wine] / dlls / dswave / dswave_main.c
1 /* DirectMusic Wave Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #include <stdio.h>
21
22 #include "dswave_private.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(dswave);
25
26 typedef struct {
27     /* IUnknown fields */
28     IClassFactoryVtbl          *lpVtbl;
29     DWORD                       ref;
30 } IClassFactoryImpl;
31
32 /******************************************************************
33  *              DirectMusicWave ClassFactory
34  */
35 static HRESULT WINAPI WaveCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
36         IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
37         FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj);
38         return E_NOINTERFACE;
39 }
40
41 static ULONG WINAPI WaveCF_AddRef(LPCLASSFACTORY iface) {
42         IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
43         return InterlockedIncrement(&This->ref);
44 }
45
46 static ULONG WINAPI WaveCF_Release(LPCLASSFACTORY iface) {
47         IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
48         /* static class, won't be  freed */
49         return InterlockedDecrement(&This->ref);
50 }
51
52 static HRESULT WINAPI WaveCF_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_CreateDirectMusicWaveImpl (riid, ppobj, pOuter);
56 }
57
58 static HRESULT WINAPI WaveCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
59         IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
60         FIXME("(%p, %d): stub\n", This, dolock);
61         return S_OK;
62 }
63
64 static IClassFactoryVtbl WaveCF_Vtbl = {
65         WaveCF_QueryInterface,
66         WaveCF_AddRef,
67         WaveCF_Release,
68         WaveCF_CreateInstance,
69         WaveCF_LockServer
70 };
71
72 static IClassFactoryImpl Wave_CF = {&WaveCF_Vtbl, 1 };
73
74 /******************************************************************
75  *              DllMain
76  *
77  *
78  */
79 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
80         if (fdwReason == DLL_PROCESS_ATTACH) {
81             DisableThreadLibraryCalls(hinstDLL);
82                 /* FIXME: Initialisation */
83         } else if (fdwReason == DLL_PROCESS_DETACH) {
84                 /* FIXME: Cleanup */
85         }
86
87         return TRUE;
88 }
89
90
91 /******************************************************************
92  *              DllCanUnloadNow (DSWAVE.1)
93  *
94  *
95  */
96 HRESULT WINAPI DSWAVE_DllCanUnloadNow(void) {
97     FIXME("(void): stub\n");
98     return S_FALSE;
99 }
100
101
102 /******************************************************************
103  *              DllGetClassObject (DSWAVE.2)
104  *
105  *
106  */
107 HRESULT WINAPI DSWAVE_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
108         TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
109         if (IsEqualCLSID (rclsid, &CLSID_DirectSoundWave) && IsEqualIID (riid, &IID_IClassFactory)) {
110                 *ppv = (LPVOID) &Wave_CF;
111                 IClassFactory_AddRef((IClassFactory*)*ppv);
112                 return S_OK;
113         }
114         
115     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
116     return CLASS_E_CLASSNOTAVAILABLE;
117 }
118
119 /******************************************************************
120  *              Helper functions
121  *
122  *
123  */
124 /* check whether the given DWORD is even (return 0) or odd (return 1) */
125 int even_or_odd (DWORD number) {
126         return (number & 0x1); /* basically, check if bit 0 is set ;) */
127 }
128
129 /* FOURCC to string conversion for debug messages */
130 const char *debugstr_fourcc (DWORD fourcc) {
131     if (!fourcc) return "'null'";
132     return wine_dbg_sprintf ("\'%c%c%c%c\'",
133                 (char)(fourcc), (char)(fourcc >> 8),
134         (char)(fourcc >> 16), (char)(fourcc >> 24));
135 }
136
137 /* DMUS_VERSION struct to string conversion for debug messages */
138 const char *debugstr_dmversion (LPDMUS_VERSION version) {
139         if (!version) return "'null'";
140         return wine_dbg_sprintf ("\'%i,%i,%i,%i\'",
141                 (int)((version->dwVersionMS && 0xFFFF0000) >> 8), (int)(version->dwVersionMS && 0x0000FFFF), 
142                 (int)((version->dwVersionLS && 0xFFFF0000) >> 8), (int)(version->dwVersionLS && 0x0000FFFF));
143 }
144
145 /* returns name of given GUID */
146 const char *debugstr_dmguid (const GUID *id) {
147         static const guid_info guids[] = {
148                 /* CLSIDs */
149                 GE(CLSID_AudioVBScript),
150                 GE(CLSID_DirectMusic),
151                 GE(CLSID_DirectMusicAudioPath),
152                 GE(CLSID_DirectMusicAudioPathConfig),
153                 GE(CLSID_DirectMusicAuditionTrack),
154                 GE(CLSID_DirectMusicBand),
155                 GE(CLSID_DirectMusicBandTrack),
156                 GE(CLSID_DirectMusicChordMapTrack),
157                 GE(CLSID_DirectMusicChordMap),
158                 GE(CLSID_DirectMusicChordTrack),
159                 GE(CLSID_DirectMusicCollection),
160                 GE(CLSID_DirectMusicCommandTrack),
161                 GE(CLSID_DirectMusicComposer),
162                 GE(CLSID_DirectMusicContainer),
163                 GE(CLSID_DirectMusicGraph),
164                 GE(CLSID_DirectMusicLoader),
165                 GE(CLSID_DirectMusicLyricsTrack),
166                 GE(CLSID_DirectMusicMarkerTrack),
167                 GE(CLSID_DirectMusicMelodyFormulationTrack),
168                 GE(CLSID_DirectMusicMotifTrack),
169                 GE(CLSID_DirectMusicMuteTrack),
170                 GE(CLSID_DirectMusicParamControlTrack),
171                 GE(CLSID_DirectMusicPatternTrack),
172                 GE(CLSID_DirectMusicPerformance),
173                 GE(CLSID_DirectMusicScript),
174                 GE(CLSID_DirectMusicScriptAutoImpSegment),
175                 GE(CLSID_DirectMusicScriptAutoImpPerformance),
176                 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
177                 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
178                 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
179                 GE(CLSID_DirectMusicScriptAutoImpSong),
180                 GE(CLSID_DirectMusicScriptSourceCodeLoader),
181                 GE(CLSID_DirectMusicScriptTrack),
182                 GE(CLSID_DirectMusicSection),
183                 GE(CLSID_DirectMusicSegment),
184                 GE(CLSID_DirectMusicSegmentState),
185                 GE(CLSID_DirectMusicSegmentTriggerTrack),
186                 GE(CLSID_DirectMusicSegTriggerTrack),
187                 GE(CLSID_DirectMusicSeqTrack),
188                 GE(CLSID_DirectMusicSignPostTrack),
189                 GE(CLSID_DirectMusicSong),
190                 GE(CLSID_DirectMusicStyle),
191                 GE(CLSID_DirectMusicStyleTrack),
192                 GE(CLSID_DirectMusicSynth),
193                 GE(CLSID_DirectMusicSynthSink),
194                 GE(CLSID_DirectMusicSysExTrack),
195                 GE(CLSID_DirectMusicTemplate),
196                 GE(CLSID_DirectMusicTempoTrack),
197                 GE(CLSID_DirectMusicTimeSigTrack),
198                 GE(CLSID_DirectMusicWaveTrack),
199                 GE(CLSID_DirectSoundWave),
200                 /* IIDs */
201                 GE(IID_IDirectMusic),
202                 GE(IID_IDirectMusic2),
203                 GE(IID_IDirectMusic8),
204                 GE(IID_IDirectMusicAudioPath),
205                 GE(IID_IDirectMusicBand),
206                 GE(IID_IDirectMusicBuffer),
207                 GE(IID_IDirectMusicChordMap),
208                 GE(IID_IDirectMusicCollection),
209                 GE(IID_IDirectMusicComposer),
210                 GE(IID_IDirectMusicContainer),
211                 GE(IID_IDirectMusicDownload),
212                 GE(IID_IDirectMusicDownloadedInstrument),
213                 GE(IID_IDirectMusicGetLoader),
214                 GE(IID_IDirectMusicGraph),
215                 GE(IID_IDirectMusicInstrument),
216                 GE(IID_IDirectMusicLoader),
217                 GE(IID_IDirectMusicLoader8),
218                 GE(IID_IDirectMusicObject),
219                 GE(IID_IDirectMusicPatternTrack),
220                 GE(IID_IDirectMusicPerformance),
221                 GE(IID_IDirectMusicPerformance2),
222                 GE(IID_IDirectMusicPerformance8),
223                 GE(IID_IDirectMusicPort),
224                 GE(IID_IDirectMusicPortDownload),
225                 GE(IID_IDirectMusicScript),
226                 GE(IID_IDirectMusicSegment),
227                 GE(IID_IDirectMusicSegment2),
228                 GE(IID_IDirectMusicSegment8),
229                 GE(IID_IDirectMusicSegmentState),
230                 GE(IID_IDirectMusicSegmentState8),
231                 GE(IID_IDirectMusicStyle),
232                 GE(IID_IDirectMusicStyle8),
233                 GE(IID_IDirectMusicSynth),
234                 GE(IID_IDirectMusicSynth8),
235                 GE(IID_IDirectMusicSynthSink),
236                 GE(IID_IDirectMusicThru),
237                 GE(IID_IDirectMusicTool),
238                 GE(IID_IDirectMusicTool8),
239                 GE(IID_IDirectMusicTrack),
240                 GE(IID_IDirectMusicTrack8),
241                 GE(IID_IUnknown),
242                 GE(IID_IPersistStream),
243                 GE(IID_IStream),
244                 GE(IID_IClassFactory),
245                 /* GUIDs */
246                 GE(GUID_DirectMusicAllTypes),
247                 GE(GUID_NOTIFICATION_CHORD),
248                 GE(GUID_NOTIFICATION_COMMAND),
249                 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
250                 GE(GUID_NOTIFICATION_PERFORMANCE),
251                 GE(GUID_NOTIFICATION_RECOMPOSE),
252                 GE(GUID_NOTIFICATION_SEGMENT),
253                 GE(GUID_BandParam),
254                 GE(GUID_ChordParam),
255                 GE(GUID_CommandParam),
256                 GE(GUID_CommandParam2),
257                 GE(GUID_CommandParamNext),
258                 GE(GUID_IDirectMusicBand),
259                 GE(GUID_IDirectMusicChordMap),
260                 GE(GUID_IDirectMusicStyle),
261                 GE(GUID_MuteParam),
262                 GE(GUID_Play_Marker),
263                 GE(GUID_RhythmParam),
264                 GE(GUID_TempoParam),
265                 GE(GUID_TimeSignature),
266                 GE(GUID_Valid_Start_Time),
267                 GE(GUID_Clear_All_Bands),
268                 GE(GUID_ConnectToDLSCollection),
269                 GE(GUID_Disable_Auto_Download),
270                 GE(GUID_DisableTempo),
271                 GE(GUID_DisableTimeSig),
272                 GE(GUID_Download),
273                 GE(GUID_DownloadToAudioPath),
274                 GE(GUID_Enable_Auto_Download),
275                 GE(GUID_EnableTempo),
276                 GE(GUID_EnableTimeSig),
277                 GE(GUID_IgnoreBankSelectForGM),
278                 GE(GUID_SeedVariations),
279                 GE(GUID_StandardMIDIFile),
280                 GE(GUID_Unload),
281                 GE(GUID_UnloadFromAudioPath),
282                 GE(GUID_Variations),
283                 GE(GUID_PerfMasterTempo),
284                 GE(GUID_PerfMasterVolume),
285                 GE(GUID_PerfMasterGrooveLevel),
286                 GE(GUID_PerfAutoDownload),
287                 GE(GUID_DefaultGMCollection),
288                 GE(GUID_Synth_Default),
289                 GE(GUID_Buffer_Reverb),
290                 GE(GUID_Buffer_EnvReverb),
291                 GE(GUID_Buffer_Stereo),
292                 GE(GUID_Buffer_3D_Dry),
293                 GE(GUID_Buffer_Mono),
294                 GE(GUID_DMUS_PROP_GM_Hardware),
295                 GE(GUID_DMUS_PROP_GS_Capable),
296                 GE(GUID_DMUS_PROP_GS_Hardware),
297                 GE(GUID_DMUS_PROP_DLS1),
298                 GE(GUID_DMUS_PROP_DLS2),
299                 GE(GUID_DMUS_PROP_Effects),
300                 GE(GUID_DMUS_PROP_INSTRUMENT2),
301                 GE(GUID_DMUS_PROP_LegacyCaps),
302                 GE(GUID_DMUS_PROP_MemorySize),
303                 GE(GUID_DMUS_PROP_SampleMemorySize),
304                 GE(GUID_DMUS_PROP_SamplePlaybackRate),
305                 GE(GUID_DMUS_PROP_SetSynthSink),
306                 GE(GUID_DMUS_PROP_SinkUsesDSound),
307                 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
308                 GE(GUID_DMUS_PROP_SynthSink_WAVE),
309                 GE(GUID_DMUS_PROP_Volume),
310                 GE(GUID_DMUS_PROP_WavesReverb),
311                 GE(GUID_DMUS_PROP_WriteLatency),
312                 GE(GUID_DMUS_PROP_WritePeriod),
313                 GE(GUID_DMUS_PROP_XG_Capable),
314                 GE(GUID_DMUS_PROP_XG_Hardware)
315         };
316
317         unsigned int i;
318
319         if (!id) return "(null)";
320
321         for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
322                 if (IsEqualGUID(id, &guids[i].guid))
323                         return guids[i].name;
324         }
325         /* if we didn't find it, act like standard debugstr_guid */     
326         return debugstr_guid(id);
327 }       
328
329 /* returns name of given error code */
330 const char *debugstr_dmreturn (DWORD code) {
331         static const flag_info codes[] = {
332                 FE(S_OK),
333                 FE(S_FALSE),
334                 FE(DMUS_S_PARTIALLOAD),
335                 FE(DMUS_S_PARTIALDOWNLOAD),
336                 FE(DMUS_S_REQUEUE),
337                 FE(DMUS_S_FREE),
338                 FE(DMUS_S_END),
339                 FE(DMUS_S_STRING_TRUNCATED),
340                 FE(DMUS_S_LAST_TOOL),
341                 FE(DMUS_S_OVER_CHORD),
342                 FE(DMUS_S_UP_OCTAVE),
343                 FE(DMUS_S_DOWN_OCTAVE),
344                 FE(DMUS_S_NOBUFFERCONTROL),
345                 FE(DMUS_S_GARBAGE_COLLECTED),
346                 FE(DMUS_E_DRIVER_FAILED),
347                 FE(DMUS_E_PORTS_OPEN),
348                 FE(DMUS_E_DEVICE_IN_USE),
349                 FE(DMUS_E_INSUFFICIENTBUFFER),
350                 FE(DMUS_E_BUFFERNOTSET),
351                 FE(DMUS_E_BUFFERNOTAVAILABLE),
352                 FE(DMUS_E_NOTADLSCOL),
353                 FE(DMUS_E_INVALIDOFFSET),
354                 FE(DMUS_E_ALREADY_LOADED),
355                 FE(DMUS_E_INVALIDPOS),
356                 FE(DMUS_E_INVALIDPATCH),
357                 FE(DMUS_E_CANNOTSEEK),
358                 FE(DMUS_E_CANNOTWRITE),
359                 FE(DMUS_E_CHUNKNOTFOUND),
360                 FE(DMUS_E_INVALID_DOWNLOADID),
361                 FE(DMUS_E_NOT_DOWNLOADED_TO_PORT),
362                 FE(DMUS_E_ALREADY_DOWNLOADED),
363                 FE(DMUS_E_UNKNOWN_PROPERTY),
364                 FE(DMUS_E_SET_UNSUPPORTED),
365                 FE(DMUS_E_GET_UNSUPPORTED),
366                 FE(DMUS_E_NOTMONO),
367                 FE(DMUS_E_BADARTICULATION),
368                 FE(DMUS_E_BADINSTRUMENT),
369                 FE(DMUS_E_BADWAVELINK),
370                 FE(DMUS_E_NOARTICULATION),
371                 FE(DMUS_E_NOTPCM),
372                 FE(DMUS_E_BADWAVE),
373                 FE(DMUS_E_BADOFFSETTABLE),
374                 FE(DMUS_E_UNKNOWNDOWNLOAD),
375                 FE(DMUS_E_NOSYNTHSINK),
376                 FE(DMUS_E_ALREADYOPEN),
377                 FE(DMUS_E_ALREADYCLOSED),
378                 FE(DMUS_E_SYNTHNOTCONFIGURED),
379                 FE(DMUS_E_SYNTHACTIVE),
380                 FE(DMUS_E_CANNOTREAD),
381                 FE(DMUS_E_DMUSIC_RELEASED),
382                 FE(DMUS_E_BUFFER_EMPTY),
383                 FE(DMUS_E_BUFFER_FULL),
384                 FE(DMUS_E_PORT_NOT_CAPTURE),
385                 FE(DMUS_E_PORT_NOT_RENDER),
386                 FE(DMUS_E_DSOUND_NOT_SET),
387                 FE(DMUS_E_ALREADY_ACTIVATED),
388                 FE(DMUS_E_INVALIDBUFFER),
389                 FE(DMUS_E_WAVEFORMATNOTSUPPORTED),
390                 FE(DMUS_E_SYNTHINACTIVE),
391                 FE(DMUS_E_DSOUND_ALREADY_SET),
392                 FE(DMUS_E_INVALID_EVENT),
393                 FE(DMUS_E_UNSUPPORTED_STREAM),
394                 FE(DMUS_E_ALREADY_INITED),
395                 FE(DMUS_E_INVALID_BAND),
396                 FE(DMUS_E_TRACK_HDR_NOT_FIRST_CK),
397                 FE(DMUS_E_TOOL_HDR_NOT_FIRST_CK),
398                 FE(DMUS_E_INVALID_TRACK_HDR),
399                 FE(DMUS_E_INVALID_TOOL_HDR),
400                 FE(DMUS_E_ALL_TOOLS_FAILED),
401                 FE(DMUS_E_ALL_TRACKS_FAILED),
402                 FE(DMUS_E_NOT_FOUND),
403                 FE(DMUS_E_NOT_INIT),
404                 FE(DMUS_E_TYPE_DISABLED),
405                 FE(DMUS_E_TYPE_UNSUPPORTED),
406                 FE(DMUS_E_TIME_PAST),
407                 FE(DMUS_E_TRACK_NOT_FOUND),
408                 FE(DMUS_E_TRACK_NO_CLOCKTIME_SUPPORT),
409                 FE(DMUS_E_NO_MASTER_CLOCK),
410                 FE(DMUS_E_LOADER_NOCLASSID),
411                 FE(DMUS_E_LOADER_BADPATH),
412                 FE(DMUS_E_LOADER_FAILEDOPEN),
413                 FE(DMUS_E_LOADER_FORMATNOTSUPPORTED),
414                 FE(DMUS_E_LOADER_FAILEDCREATE),
415                 FE(DMUS_E_LOADER_OBJECTNOTFOUND),
416                 FE(DMUS_E_LOADER_NOFILENAME),
417                 FE(DMUS_E_INVALIDFILE),
418                 FE(DMUS_E_ALREADY_EXISTS),
419                 FE(DMUS_E_OUT_OF_RANGE),
420                 FE(DMUS_E_SEGMENT_INIT_FAILED),
421                 FE(DMUS_E_ALREADY_SENT),
422                 FE(DMUS_E_CANNOT_FREE),
423                 FE(DMUS_E_CANNOT_OPEN_PORT),
424                 FE(DMUS_E_CANNOT_CONVERT),
425                 FE(DMUS_E_DESCEND_CHUNK_FAIL),
426                 FE(DMUS_E_NOT_LOADED),
427                 FE(DMUS_E_SCRIPT_LANGUAGE_INCOMPATIBLE),
428                 FE(DMUS_E_SCRIPT_UNSUPPORTED_VARTYPE),
429                 FE(DMUS_E_SCRIPT_ERROR_IN_SCRIPT),
430                 FE(DMUS_E_SCRIPT_CANTLOAD_OLEAUT32),
431                 FE(DMUS_E_SCRIPT_LOADSCRIPT_ERROR),
432                 FE(DMUS_E_SCRIPT_INVALID_FILE),
433                 FE(DMUS_E_INVALID_SCRIPTTRACK),
434                 FE(DMUS_E_SCRIPT_VARIABLE_NOT_FOUND),
435                 FE(DMUS_E_SCRIPT_ROUTINE_NOT_FOUND),
436                 FE(DMUS_E_SCRIPT_CONTENT_READONLY),
437                 FE(DMUS_E_SCRIPT_NOT_A_REFERENCE),
438                 FE(DMUS_E_SCRIPT_VALUE_NOT_SUPPORTED),
439                 FE(DMUS_E_INVALID_SEGMENTTRIGGERTRACK),
440                 FE(DMUS_E_INVALID_LYRICSTRACK),
441                 FE(DMUS_E_INVALID_PARAMCONTROLTRACK),
442                 FE(DMUS_E_AUDIOVBSCRIPT_SYNTAXERROR),
443                 FE(DMUS_E_AUDIOVBSCRIPT_RUNTIMEERROR),
444                 FE(DMUS_E_AUDIOVBSCRIPT_OPERATIONFAILURE),
445                 FE(DMUS_E_AUDIOPATHS_NOT_VALID),
446                 FE(DMUS_E_AUDIOPATHS_IN_USE),
447                 FE(DMUS_E_NO_AUDIOPATH_CONFIG),
448                 FE(DMUS_E_AUDIOPATH_INACTIVE),
449                 FE(DMUS_E_AUDIOPATH_NOBUFFER),
450                 FE(DMUS_E_AUDIOPATH_NOPORT),
451                 FE(DMUS_E_NO_AUDIOPATH),
452                 FE(DMUS_E_INVALIDCHUNK),
453                 FE(DMUS_E_AUDIOPATH_NOGLOBALFXBUFFER),
454                 FE(DMUS_E_INVALID_CONTAINER_OBJECT)
455         };
456         unsigned int i;
457         for (i = 0; i < sizeof(codes)/sizeof(codes[0]); i++) {
458                 if (code == codes[i].val)
459                         return codes[i].name;
460         }
461         /* if we didn't find it, return value */
462         return wine_dbg_sprintf("0x%08lx", code);
463 }
464
465 /* generic flag-dumping function */
466 const char* debugstr_flags (DWORD flags, const flag_info* names, size_t num_names){
467         char buffer[128] = "", *ptr = &buffer[0];
468         unsigned int i, size = sizeof(buffer);
469         
470         for (i=0; i < num_names; i++)
471         {
472                 if ((flags & names[i].val) ||   /* standard flag*/
473                         ((!flags) && (!names[i].val))) { /* zero value only */
474                                 int cnt = snprintf(ptr, size, "%s ", names[i].name);
475                                 if (cnt < 0 || cnt >= size) break;
476                                 size -= cnt;
477                                 ptr += cnt;
478                 }
479         }
480         
481         return wine_dbg_sprintf("%s", buffer);
482 }
483
484 /* dump DMUS_OBJ flags */
485 const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) {
486     static const flag_info flags[] = {
487             FE(DMUS_OBJ_OBJECT),
488             FE(DMUS_OBJ_CLASS),
489             FE(DMUS_OBJ_NAME),
490             FE(DMUS_OBJ_CATEGORY),
491             FE(DMUS_OBJ_FILENAME),
492             FE(DMUS_OBJ_FULLPATH),
493             FE(DMUS_OBJ_URL),
494             FE(DMUS_OBJ_VERSION),
495             FE(DMUS_OBJ_DATE),
496             FE(DMUS_OBJ_LOADED),
497             FE(DMUS_OBJ_MEMORY),
498             FE(DMUS_OBJ_STREAM)
499         };
500     return debugstr_flags (flagmask, flags, sizeof(flags)/sizeof(flags[0]));
501 }
502
503 /* dump whole DMUS_OBJECTDESC struct */
504 const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
505         if (pDesc) {
506                 char buffer[1024] = "", *ptr = &buffer[0];
507                 
508                 ptr += sprintf(ptr, "DMUS_OBJECTDESC (%p):\n", pDesc);
509                 ptr += sprintf(ptr, " - dwSize = %ld\n", pDesc->dwSize);
510                 ptr += sprintf(ptr, " - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData));
511                 if (pDesc->dwValidData & DMUS_OBJ_CLASS) ptr += sprintf(ptr, " - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass));
512                 if (pDesc->dwValidData & DMUS_OBJ_OBJECT) ptr += sprintf(ptr, " - guidObject = %s\n", debugstr_guid(&pDesc->guidObject));
513                 if (pDesc->dwValidData & DMUS_OBJ_DATE) ptr += sprintf(ptr, " - ftDate = FIXME\n");
514                 if (pDesc->dwValidData & DMUS_OBJ_VERSION) ptr += sprintf(ptr, " - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion));
515                 if (pDesc->dwValidData & DMUS_OBJ_NAME) ptr += sprintf(ptr, " - wszName = %s\n", debugstr_w(pDesc->wszName));
516                 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) ptr += sprintf(ptr, " - wszCategory = %s\n", debugstr_w(pDesc->wszCategory));
517                 if (pDesc->dwValidData & DMUS_OBJ_FILENAME) ptr += sprintf(ptr, " - wszFileName = %s\n", debugstr_w(pDesc->wszFileName));
518                 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) ptr += sprintf(ptr, " - llMemLength = %lli\n  - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData);
519                 if (pDesc->dwValidData & DMUS_OBJ_STREAM) ptr += sprintf(ptr, " - pStream = %p", pDesc->pStream);
520
521                 return wine_dbg_sprintf("%s", buffer);
522         } else {
523                 return wine_dbg_sprintf("(NULL)");
524         }
525 }