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