diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/fmopl.cpp | 14 | ||||
-rw-r--r-- | audio/fmopl.h | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/audio/fmopl.cpp b/audio/fmopl.cpp index 30229ea6bf..00e49ef598 100644 --- a/audio/fmopl.cpp +++ b/audio/fmopl.cpp @@ -63,6 +63,15 @@ Config::DriverId Config::parse(const Common::String &name) { return -1; } +const Config::EmulatorDescription *Config::findDriver(DriverId id) { + for (int i = 0; _drivers[i].name; ++i) { + if (_drivers[i].id == id) + return &_drivers[i]; + } + + return 0; +} + Config::DriverId Config::detect(OplType type) { uint32 flags = 0; switch (type) { @@ -90,8 +99,11 @@ Config::DriverId Config::detect(OplType type) { // When a valid driver is selected, check whether it supports // the requested OPL chip. if (drv != -1 && drv != kAuto) { + const EmulatorDescription *driverDesc = findDriver(drv); // If the chip is supported, just use the driver. - if ((flags & _drivers[drv].flags)) { + if (!driverDesc) { + warning("The selected OPL driver %d could not be found", drv); + } else if ((flags & driverDesc->flags)) { return drv; } else { // Else we will output a warning and just diff --git a/audio/fmopl.h b/audio/fmopl.h index 85ac606c7a..28dd456e21 100644 --- a/audio/fmopl.h +++ b/audio/fmopl.h @@ -71,6 +71,12 @@ public: static DriverId parse(const Common::String &name); /** + * @return The driver description for the given id or 0 in case it is not + * available. + */ + static const EmulatorDescription *findDriver(DriverId id); + + /** * Detects a driver for the specific type. * * @return Returns a valid driver id on success, -1 otherwise. |