aboutsummaryrefslogtreecommitdiff
path: root/audio/mididrv.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-07-20 09:27:39 -0400
committerMatthew Hoops2011-07-20 09:27:39 -0400
commitad293b249e74dd1cfbdbd721d02145efbdaf9eca (patch)
treee568d96f6d7f64c5e58b4c7cd1c4fda7e649bfc7 /audio/mididrv.cpp
parentd7411acc2b1c7702280dbff1c3e1bafee528184b (diff)
parente25e85fbb047fef895ede97c3c2c73451631052c (diff)
downloadscummvm-rg350-ad293b249e74dd1cfbdbd721d02145efbdaf9eca.tar.gz
scummvm-rg350-ad293b249e74dd1cfbdbd721d02145efbdaf9eca.tar.bz2
scummvm-rg350-ad293b249e74dd1cfbdbd721d02145efbdaf9eca.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'audio/mididrv.cpp')
-rw-r--r--audio/mididrv.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp
index 0ca70b24f8..27f02c9053 100644
--- a/audio/mididrv.cpp
+++ b/audio/mididrv.cpp
@@ -128,7 +128,8 @@ Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType
MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// Query the selected music device (defaults to MT_AUTO device).
- DeviceHandle hdl = getDeviceHandle(ConfMan.get("music_driver"));
+ Common::String selDevStr = ConfMan.hasKey("music_driver") ? ConfMan.get("music_driver") : Common::String("auto");
+ DeviceHandle hdl = getDeviceHandle(selDevStr.empty() ? Common::String("auto") : selDevStr);
DeviceHandle reslt = 0;
_forceTypeMT32 = false;
@@ -200,7 +201,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
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");
+ failedDevStr = selDevStr;
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();
@@ -229,14 +230,16 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
if ((flags & MDT_MIDI) && !skipMidi) {
// If a preferred MT32 or GM device has been selected that device gets returned if available.
Common::String devStr;
- if (flags & MDT_PREFER_MT32)
- devStr = ConfMan.get("mt32_device");
+ if (flags & MDT_PREFER_MT32)
+ devStr = ConfMan.hasKey("mt32_device") ? ConfMan.get("mt32_device") : Common::String("null");
else if (flags & MDT_PREFER_GM)
- devStr = ConfMan.get("gm_device");
+ devStr = ConfMan.hasKey("gm_device") ? ConfMan.get("gm_device") : Common::String("null");
else
devStr = "auto";
-
- hdl = getDeviceHandle(devStr);
+
+ // Default to Null device here, since we also register a default null setting for
+ // the MT32 or GM device in the config manager.
+ hdl = getDeviceHandle(devStr.empty() ? Common::String("null") : devStr);
const MusicType type = getMusicType(hdl);
// If we have a "Don't use GM/MT-32" setting we skip this part and jump
@@ -261,7 +264,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// 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)) {
+ if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) {
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();
@@ -285,7 +288,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
}
}
- // Now we default to the first available device with music type 'MT_GM' if not
+ // Now we default to the first available device with music type 'MT_GM' if not
// MT-32 is preferred or if MT-32 is preferred but all other devices have failed.
if (!(flags & MDT_PREFER_MT32) || flags == (MDT_PREFER_MT32 | MDT_MIDI)) {
for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) {