mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-18 18:11:05 +00:00
Improve error reporting in Waveout and DSound drivers
This commit is contained in:
parent
b5da68393c
commit
abc89d7d6c
4 changed files with 74 additions and 12 deletions
|
@ -292,7 +292,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(hr != DS_OK)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create the DirectSound object");
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create the DirectSound object: '%s'", fluid_win32_error(hr));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(hr != DS_OK)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to set the cooperative level");
|
||||
FLUID_LOG(FLUID_ERR, "Failed to set the cooperative level: '%s'", fluid_win32_error(hr));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(hr != DS_OK)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to query the device capacities");
|
||||
FLUID_LOG(FLUID_ERR, "Failed to query the device capacities: '%s'", fluid_win32_error(hr));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(hr != DS_OK)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to allocate the primary buffer");
|
||||
FLUID_LOG(FLUID_ERR, "Failed to allocate the primary buffer: '%s'", fluid_win32_error(hr));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(hr != DS_OK)
|
||||
{
|
||||
FLUID_LOG(FLUID_WARN, "Can't set format of primary sound buffer: %s", fluid_win32_error(hr));
|
||||
FLUID_LOG(FLUID_WARN, "Can't set format of primary sound buffer: '%s'", fluid_win32_error(hr));
|
||||
}
|
||||
|
||||
/* initialize the buffer description */
|
||||
|
@ -364,7 +364,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(hr != DS_OK)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "dsound: Can't create sound buffer: %s", fluid_win32_error(hr));
|
||||
FLUID_LOG(FLUID_ERR, "dsound: Can't create sound buffer: '%s'", fluid_win32_error(hr));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if((hr != DS_OK) || (buf1 == NULL))
|
||||
{
|
||||
FLUID_LOG(FLUID_PANIC, "Failed to lock the audio buffer. Exiting.");
|
||||
FLUID_LOG(FLUID_PANIC, "Failed to lock the audio buffer: '%s'", fluid_win32_error(hr));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -389,6 +389,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(dev->quit_ev == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create quit Event: '%s'", fluid_get_windows_error());
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -397,6 +398,7 @@ new_fluid_dsound_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(dev->thread == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create DSound audio thread: '%s'", fluid_get_windows_error());
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -540,7 +542,7 @@ static DWORD WINAPI fluid_dsound_audio_run(LPVOID lpParameter)
|
|||
if((res != DS_OK) || (buf1 == NULL))
|
||||
{
|
||||
FLUID_LOG(FLUID_PANIC, "Failed to lock the audio buffer. System lockup might follow. Exiting.");
|
||||
ExitProcess(0);
|
||||
ExitProcess((UINT)-1);
|
||||
}
|
||||
|
||||
/* fill the first part of the buffer */
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
/* Maximum number of stereo outputs */
|
||||
#define WAVEOUT_MAX_STEREO_CHANNELS 4
|
||||
|
||||
static char *fluid_waveout_error(MMRESULT hr);
|
||||
|
||||
/* speakers mapping */
|
||||
const static DWORD channel_mask_speakers[WAVEOUT_MAX_STEREO_CHANNELS] =
|
||||
{
|
||||
|
@ -144,7 +146,7 @@ static DWORD WINAPI fluid_waveout_synth_thread(void *data)
|
|||
|
||||
if(code < 0)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "fluid_waveout_synth_thread: GetMessage() failed.");
|
||||
FLUID_LOG(FLUID_ERR, "fluid_waveout_synth_thread: GetMessage() failed: '%s'", fluid_get_windows_error());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -391,7 +393,7 @@ new_fluid_waveout_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(dev->hQuit == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create quit event");
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create quit event: '%s'", fluid_get_windows_error());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -407,7 +409,7 @@ new_fluid_waveout_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(dev->hThread == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create waveOut thread");
|
||||
FLUID_LOG(FLUID_ERR, "Failed to create waveOut thread: '%s'", fluid_get_windows_error());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -420,7 +422,7 @@ new_fluid_waveout_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
|
||||
if(errCode != MMSYSERR_NOERROR)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to open waveOut device");
|
||||
FLUID_LOG(FLUID_ERR, "Failed to open waveOut device: '%s'", fluid_waveout_error());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -492,4 +494,42 @@ void delete_fluid_waveout_audio_driver(fluid_audio_driver_t *d)
|
|||
HeapFree(GetProcessHeap(), 0, dev);
|
||||
}
|
||||
|
||||
static char *fluid_waveout_error(MMRESULT hr)
|
||||
{
|
||||
char *s = "Don't know why";
|
||||
|
||||
switch(hr)
|
||||
{
|
||||
case MMSYSERR_NOERROR:
|
||||
s = "The operation completed successfully :)";
|
||||
break;
|
||||
|
||||
case MMSYSERR_ALLOCATED:
|
||||
s = "Specified resource is already allocated.";
|
||||
break;
|
||||
|
||||
case MMSYSERR_BADDEVICEID:
|
||||
s = "Specified device identifier is out of range";
|
||||
break;
|
||||
|
||||
case MMSYSERR_NODRIVER:
|
||||
s = "No device driver is present";
|
||||
break;
|
||||
|
||||
case MMSYSERR_NOMEM:
|
||||
s = "Unable to allocate or lock memory";
|
||||
break;
|
||||
|
||||
case WAVERR_BADFORMAT:
|
||||
s = "Attempted to open with an unsupported waveform-audio format";
|
||||
break;
|
||||
|
||||
case WAVERR_SYNC:
|
||||
s = "The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag";
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif /* WAVEOUT_SUPPORT */
|
||||
|
|
|
@ -1692,3 +1692,20 @@ fluid_long_long_t fluid_file_tell(FILE* f)
|
|||
return ftell(f);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// not thread-safe!
|
||||
char* fluid_get_windows_error(void)
|
||||
{
|
||||
static const char err[1024];
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
||||
err,
|
||||
sizeof(err)/sizeof(err[0]),
|
||||
NULL);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -167,6 +167,9 @@ typedef gintptr intptr_t;
|
|||
*/
|
||||
#define fluid_gerror_message(err) ((err) ? err->message : "No error details")
|
||||
|
||||
#ifdef WIN32
|
||||
char* fluid_get_windows_error(void);
|
||||
#endif
|
||||
|
||||
#define FLUID_INLINE inline
|
||||
|
||||
|
|
Loading…
Reference in a new issue