diff options
-rw-r--r-- | base/commandLine.cpp | 4 | ||||
-rw-r--r-- | base/main.cpp | 11 | ||||
-rw-r--r-- | sound/mididrv.cpp | 4 |
3 files changed, 15 insertions, 4 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 8b0decf695..ee35bcf4c3 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -32,8 +32,6 @@ #include "common/system.h" #include "common/fs.h" -#include "sound/mididrv.h" - #include "gui/ThemeEngine.h" #define DETECTOR_TESTING_HACK @@ -364,8 +362,6 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha END_OPTION DO_OPTION('e', "music-driver") - if (MidiDriver::getMusicType(MidiDriver::getDeviceHandle(option)) == MT_NULL) - usage("Unrecognized music driver '%s'", option); END_OPTION DO_LONG_OPTION_INT("output-rate") diff --git a/base/main.cpp b/base/main.cpp index 0360c89502..1e3edb1534 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -54,6 +54,7 @@ #include "gui/error.h" #include "sound/audiocd.h" +#include "sound/mididrv.h" #include "backends/keymapper/keymapper.h" @@ -341,6 +342,16 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { // Load the plugins. PluginManager::instance().loadPlugins(); + // If we received an invalid music parameter via command line we check this here. + // We can't check this before loading the music plugins. + // On the other hand we cannot load the plugins before we know the file paths (in case of external plugins). + if (!settings["music-driver"].empty()) { + if (MidiDriver::getMusicType(MidiDriver::getDeviceHandle(settings["music-driver"])) == MT_NULL) { + warning("Unrecognized music driver '%s'\nSwitching to default device.", settings["music-driver"].c_str()); + settings["music-driver"] = "auto"; + } + } + // Process the remaining command line settings. Must be done after the // config file and the plugins have been loaded. Common::Error res; diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 4faff04d9c..d185626f62 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -238,6 +238,10 @@ MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) { MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &identifier) { const MusicPlugin::List p = MusicMan.getPlugins(); + + if (p.begin() == p.end()) + error("Music plugins must be loaded prior to calling this method."); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { |