[Scummvm-cvs-logs] scummvm master -> d6e23ac67b23b850147f519a88b9230997d9c877

athrxx athrxx at scummvm.org
Tue Jun 7 18:36:43 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d6e23ac67b AUDIO: improved warnings in detectDevice()


Commit: d6e23ac67b23b850147f519a88b9230997d9c877
    https://github.com/scummvm/scummvm/commit/d6e23ac67b23b850147f519a88b9230997d9c877
Author: athrxx (athrxx at scummvm.org)
Date: 2011-06-07T09:28:28-07:00

Commit Message:
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.

Changed paths:
    audio/mididrv.cpp



diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp
index 22d473a..80981ee 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();
 						}






More information about the Scummvm-git-logs mailing list