[Scummvm-cvs-logs] SF.net SVN: scummvm:[40502] scummvm/trunk/sound

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue May 12 21:03:54 CEST 2009


Revision: 40502
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40502&view=rev
Author:   lordhoto
Date:     2009-05-12 19:03:54 +0000 (Tue, 12 May 2009)

Log Message:
-----------
Cleanup.

Modified Paths:
--------------
    scummvm/trunk/sound/fmopl.cpp
    scummvm/trunk/sound/fmopl.h

Modified: scummvm/trunk/sound/fmopl.cpp
===================================================================
--- scummvm/trunk/sound/fmopl.cpp	2009-05-12 19:03:42 UTC (rev 40501)
+++ scummvm/trunk/sound/fmopl.cpp	2009-05-12 19:03:54 UTC (rev 40502)
@@ -34,12 +34,13 @@
 // Config implementation
 
 enum OplEmulator {
+	kAuto = 0,
 	kMame = 1,
 	kDOSBox = 2
 };
 
 const Config::EmulatorDescription Config::_drivers[] = {
-	{ "auto", "<default>", 0, kFlagOpl2 | kFlagDualOpl2 | kFlagOpl3 },
+	{ "auto", "<default>", kAuto, kFlagOpl2 | kFlagDualOpl2 | kFlagOpl3 },
 	{ "mame", "MAME OPL emulator", kMame, kFlagOpl2 },
 #ifndef DISABLE_DOSBOX_OPL
 	{ "db", "DOSBox OPL emulator (experimental)", kDOSBox, kFlagOpl2 | kFlagDualOpl2 | kFlagOpl3 },
@@ -53,7 +54,7 @@
 			return _drivers[i].id;
 	}
 
-	return 0;
+	return -1;
 }
 
 Config::DriverId Config::detect(OplType type) {
@@ -76,12 +77,13 @@
 
 	// When a valid driver is selected, check whether it supports
 	// the requested OPL chip.
-	if (validDriver(drv)) {
+	if (drv != -1 && drv != kAuto) {
 		// If the chip is supported, just use the driver.
 		if ((flags & _drivers[drv].flags))
 			return drv;
-
 		// When it doesn't support the flags fall back to auto detection
+		else
+			drv = -1;
 	}
 
 	// Detect the first matching emulator
@@ -96,10 +98,26 @@
 }
 
 OPL *Config::create(DriverId driver, OplType type) {
-	if (!validDriver(driver))
+	// On invalid driver selection, we try to do some fallback detection
+	if (driver == -1) {
+		warning("Invalid OPL driver selected, trying to detect a fallback emulator");
+		driver = kAuto;
+	}
+
+	// If autodetection is selected, we search for a matching
+	// driver.
+	if (driver == kAuto) {
 		driver = detect(type);
 
-	switch (driver)  {
+		// No emulator for the specified OPL chip could
+		// be found, thus stop here.
+		if (driver == -1) {
+			warning("No OPL emulator available for type %d", type);
+			return 0;
+		}
+	}
+
+	switch (driver) {
 	case kMame:
 		if (type == kOpl2)
 			return new MAME::OPL();

Modified: scummvm/trunk/sound/fmopl.h
===================================================================
--- scummvm/trunk/sound/fmopl.h	2009-05-12 19:03:42 UTC (rev 40501)
+++ scummvm/trunk/sound/fmopl.h	2009-05-12 19:03:54 UTC (rev 40502)
@@ -75,11 +75,6 @@
 	static DriverId detect(OplType type = kOpl2);
 
 	/**
-	 * Checks whether the driver id is valid.
-	 */
-	static bool validDriver(DriverId id) { return (id > 0); }
-
-	/**
 	 * Creates the specific driver with a specific type setup.
 	 */ 
 	static OPL *create(DriverId driver, OplType type);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list