[Scummvm-git-logs] scummvm master -> 645b8666005db932da13a9d263d95f0abd84aac1

sev- noreply at scummvm.org
Sun Apr 5 22:37:45 UTC 2026


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

Summary:
4626f657fd AUDIO: Add a null OPL implementation
645b866600 AUDIO: Skip AdLib MIDI output when OPL is disabled or unavailable


Commit: 4626f657fdbe239472c9a7bad3cd663cd13f8d8a
    https://github.com/scummvm/scummvm/commit/4626f657fdbe239472c9a7bad3cd663cd13f8d8a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-06T00:37:42+02:00

Commit Message:
AUDIO: Add a null OPL implementation

Changed paths:
    audio/fmopl.cpp
    audio/fmopl.h


diff --git a/audio/fmopl.cpp b/audio/fmopl.cpp
index 5e7ca91a46c..e24cfff6642 100644
--- a/audio/fmopl.cpp
+++ b/audio/fmopl.cpp
@@ -57,14 +57,15 @@ namespace RetroWaveOPL3 {
 // Config implementation
 
 enum OplEmulator {
-	kAuto = 0,
-	kMame = 1,
-	kDOSBox = 2,
-	kALSA = 3,
-	kNuked = 4,
-	kOPL2LPT = 5,
-	kOPL3LPT = 6,
-	kRWOPL3 = 7
+	kNull = 0,
+	kAuto = 1,
+	kMame = 2,
+	kDOSBox = 3,
+	kALSA = 4,
+	kNuked = 5,
+	kOPL2LPT = 6,
+	kOPL3LPT = 7,
+	kRWOPL3 = 8
 };
 
 OPL::OPL() {
@@ -79,6 +80,7 @@ OPL::OPL() {
 
 const Config::EmulatorDescription Config::_drivers[] = {
 	{ "auto", "<default>", kAuto, kFlagOpl2 | kFlagDualOpl2 | kFlagOpl3 },
+	{ "null", _s("None"), kNull, kFlagOpl2 | kFlagDualOpl2 | kFlagOpl3 },
 	{ "mame", _s("MAME OPL emulator"), kMame, kFlagOpl2 },
 #ifndef DISABLE_DOSBOX_OPL
 	{ "db", _s("DOSBox OPL emulator"), kDOSBox, kFlagOpl2 | kFlagDualOpl2 | kFlagOpl3 },
@@ -164,7 +166,7 @@ Config::DriverId Config::detect(OplType type) {
 	// Detect the first matching emulator
 	drv = -1;
 
-	for (int i = 1; _drivers[i].name; ++i) {
+	for (int i = 2; _drivers[i].name; ++i) {
 		if (_drivers[i].flags & flags) {
 			drv = _drivers[i].id;
 			break;
@@ -238,10 +240,11 @@ OPL *Config::create(DriverId driver, OplType type) {
 		return RetroWaveOPL3::create(type);
 #endif
 
+	case kNull:
+		return new NullOPL();
+
 	default:
 		warning("Unsupported OPL emulator %d", driver);
-		// TODO: Maybe we should add some dummy emulator too, which just outputs
-		// silence as sound?
 		return nullptr;
 	}
 }
diff --git a/audio/fmopl.h b/audio/fmopl.h
index 76361c05854..f3c2e363e81 100644
--- a/audio/fmopl.h
+++ b/audio/fmopl.h
@@ -90,7 +90,8 @@ public:
 	/**
 	 * Detects a driver for the specific type.
 	 *
-	 * @return Returns a valid driver id on success, -1 otherwise.
+	 * @return Returns a valid driver id on success, 0 for null device,
+	 *         -1 on failure.
 	 */
 	static DriverId detect(OplType type);
 
@@ -187,6 +188,18 @@ protected:
 	int _connectionFeedbackValues[3];
 };
 
+/**
+ * A null implementation of a Yamaha OPL chip that runs the callback
+ * but doesn't output any audio.
+ */
+class NullOPL final : public ::OPL::OPL, public Audio::RealChip {
+public:
+	bool init() override { return true; }
+	void reset() override {}
+	void write(int a, int v) override {}
+	void writeReg(int r, int v) override {}
+};
+
 /** @} */
 } // End of namespace OPL
 


Commit: 645b8666005db932da13a9d263d95f0abd84aac1
    https://github.com/scummvm/scummvm/commit/645b8666005db932da13a9d263d95f0abd84aac1
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-06T00:37:42+02:00

Commit Message:
AUDIO: Skip AdLib MIDI output when OPL is disabled or unavailable

Changed paths:
    audio/adlib.cpp
    audio/mididrv.cpp


diff --git a/audio/adlib.cpp b/audio/adlib.cpp
index 3b5f7bfd161..bb746af8fa7 100644
--- a/audio/adlib.cpp
+++ b/audio/adlib.cpp
@@ -2312,14 +2312,23 @@ public:
 
 MusicDevices AdLibEmuMusicPlugin::getDevices() const {
 	MusicDevices devices;
-	devices.push_back(MusicDevice(this, "", MT_ADLIB));
+
+	if (OPL::Config::detect(OPL::Config::kOpl2) > 0 ||
+	    OPL::Config::detect(OPL::Config::kOpl3) > 0) {
+		devices.push_back(MusicDevice(this, "", MT_ADLIB));
+	}
+
 	return devices;
 }
 
 Common::Error AdLibEmuMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
-	*mididriver = new MidiDriver_ADLIB();
+	if (OPL::Config::detect(OPL::Config::kOpl2) > 0 ||
+	    OPL::Config::detect(OPL::Config::kOpl3) > 0) {
+		*mididriver = new MidiDriver_ADLIB();
+		return Common::kNoError;
+	}
 
-	return Common::kNoError;
+	return Common::kAudioDeviceInitFailed;
 }
 
 //#if PLUGIN_ENABLED_DYNAMIC(ADLIB)
diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp
index f90284e729e..6285dafb367 100644
--- a/audio/mididrv.cpp
+++ b/audio/mididrv.cpp
@@ -338,6 +338,11 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
 					// Detection flags get removed after final detection attempt to avoid further attempts.
 					flags &= ~(MDT_MIDI | MDT_PREFER_GM | MDT_PREFER_MT32);
 				}
+			} else {
+				if (flags & MDT_PREFER_MT32)
+					flags &= ~MDT_PREFER_MT32;
+				else if (flags & MDT_PREFER_GM)
+					flags &= ~MDT_PREFER_GM;
 			}
 		}
 




More information about the Scummvm-git-logs mailing list