diff options
author | athrxx | 2011-06-07 18:27:13 +0200 |
---|---|---|
committer | athrxx | 2011-06-07 18:28:28 +0200 |
commit | d6e23ac67b23b850147f519a88b9230997d9c877 (patch) | |
tree | bf16874da1e294faf8bc1ea6bcbff54ccb837e38 /audio | |
parent | b6a9901e0a40ac838822fc2bc959801a6f2d62fa (diff) | |
download | scummvm-rg350-d6e23ac67b23b850147f519a88b9230997d9c877.tar.gz scummvm-rg350-d6e23ac67b23b850147f519a88b9230997d9c877.tar.bz2 scummvm-rg350-d6e23ac67b23b850147f519a88b9230997d9c877.zip |
AUDIO: improved warnings in detectDevice()
Silent fallback would occur if the user expressly selected a formerly available audio device which now has become unavailable (switched off, disconnected, no longer compiled in, etc.). A warning dialogue will now be displayed, before the fallback takes place.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/mididrv.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp index 22d473a518..80981eeccb 100644 --- a/audio/mididrv.cpp +++ b/audio/mididrv.cpp @@ -190,20 +190,30 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { case MT_NULL: reslt = hdl; + break; default: break; } Common::String failedDevStr; + if (getMusicType(hdl) == MT_INVALID) { + // If the expressly selected driver or device cannot be found (no longer compiled in, turned off, etc.) + // we display a warning and continue. + failedDevStr = ConfMan.get("music_driver"); + Common::String warningMsg = Common::String::format(_("The selected audio device '%s' was not found (e.g. might be turned off or disconnected). Attempting to fall back to the next available device..."), failedDevStr.c_str()); + GUI::MessageDialog dialog(warningMsg); + dialog.runModal(); + } + MusicType tp = getMusicType(reslt); if (tp != MT_INVALID && tp != MT_AUTO) { if (checkDevice(reslt)) { return reslt; } else { - // If the expressly selected device is unavailable we display a warning and continue. + // If the expressly selected device cannot be used we display a warning and continue. failedDevStr = getDeviceString(hdl, MidiDriver::kDeviceName); - Common::String warningMsg = Common::String::format(_("Failed to detect the selected audio device '%s'. See log file for more information. Attempting to fall back to the next available device..."), failedDevStr.c_str()); + Common::String warningMsg = Common::String::format(_("The selected audio device '%s' cannot be used. See log file for more information. Attempting to fall back to the next available device..."), failedDevStr.c_str()); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -220,30 +230,41 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { while (flags != MDT_NONE) { if ((flags & MDT_MIDI) && !skipMidi) { // If a preferred MT32 or GM device has been selected that device gets returned if available. - if (flags & MDT_PREFER_MT32) - hdl = getDeviceHandle(ConfMan.get("mt32_device")); + Common::String devStr; + if (flags & MDT_PREFER_MT32) + devStr = ConfMan.get("mt32_device"); else if (flags & MDT_PREFER_GM) - hdl = getDeviceHandle(ConfMan.get("gm_device")); + devStr = ConfMan.get("gm_device"); else - hdl = getDeviceHandle("auto"); + devStr = "auto"; + hdl = getDeviceHandle(devStr); const MusicType type = getMusicType(hdl); // If we have a "Don't use GM/MT-32" setting we skip this part and jump // to AdLib, PC Speaker etc. detection right away. if (type != MT_NULL) { - if (type != MT_AUTO && type != MT_INVALID) { + if (type == MT_INVALID) { + // If the preferred (expressly requested) selected driver or device cannot be found (no longer compiled in, turned off, etc.) + // we display a warning and continue. Don't warn about the missing device if we did already (this becomes relevant if the + // missing device is selected as preferred device and also as GM or MT-32 device). + if (failedDevStr != devStr) { + Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected). Attempting to fall back to the next available device..."), devStr.c_str()); + GUI::MessageDialog dialog(warningMsg); + dialog.runModal(); + } + } else if (type != MT_AUTO) { if (checkDevice(hdl)) { if (flags & MDT_PREFER_MT32) // If we have a preferred MT32 device we disable the gm/mt32 mapping (more about this in mididrv.h). _forceTypeMT32 = true; return hdl; } else { - // If the preferred (expressly requested) device is unavailable we display a warning and continue. - // Don't warn about the missing device if we did already (this becomes relevant if the failing + // If the preferred (expressly requested) device cannot be used we display a warning and continue. + // Don't warn about the failing device if we did already (this becomes relevant if the failing // device is selected as preferred device and also as GM or MT-32 device). if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) { - Common::String warningMsg = Common::String::format(_("Failed to detect the preferred device '%s'. See log file for more information. Attempting to fall back to the next available device..."), getDeviceString(hdl, MidiDriver::kDeviceName).c_str()); + Common::String warningMsg = Common::String::format(_("The preferred audio device '%s' cannot be used. See log file for more information. Attempting to fall back to the next available device..."), getDeviceString(hdl, MidiDriver::kDeviceName).c_str()); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } |