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