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