diff --git a/src/sound/music_fluidsynth_mididevice.cpp b/src/sound/music_fluidsynth_mididevice.cpp index 9777494fd..fd0bab645 100644 --- a/src/sound/music_fluidsynth_mididevice.cpp +++ b/src/sound/music_fluidsynth_mididevice.cpp @@ -96,6 +96,8 @@ // PUBLIC DATA DEFINITIONS ------------------------------------------------- +CVAR(String, fluid_lib, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + CVAR(String, fluid_patchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CUSTOM_CVAR(Float, fluid_gain, 0.5, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) @@ -693,22 +695,54 @@ bool FluidSynthMIDIDevice::LoadFluidSynth() const char *libname; #ifdef _WIN32 - FluidSynthDLL = LoadLibrary((libname = FLUIDSYNTHLIB1)); - if (FluidSynthDLL == NULL) + if (strlen(fluid_lib) > 0) { - FluidSynthDLL = LoadLibrary((libname = FLUIDSYNTHLIB2)); - if (FluidSynthDLL == NULL) + FluidSynthDLL = LoadLibrary(libname = fluid_lib); + if (nullptr == FluidSynthDLL) { - Printf(TEXTCOLOR_RED"Could not load " FLUIDSYNTHLIB1 " or " FLUIDSYNTHLIB2 "\n"); - return false; + Printf(TEXTCOLOR_RED "Could not load %s\n", libname); + } + } + else + { + FluidSynthDLL = nullptr; + } + + if (nullptr == FluidSynthDLL) + { + FluidSynthDLL = LoadLibrary(libname = FLUIDSYNTHLIB1); + if (nullptr == FluidSynthDLL) + { + FluidSynthDLL = LoadLibrary(libname = FLUIDSYNTHLIB2); + if (nullptr == FluidSynthDLL) + { + Printf(TEXTCOLOR_RED "Could not load " FLUIDSYNTHLIB1 " or " FLUIDSYNTHLIB2 "\n"); + return false; + } } } #else - FluidSynthSO = dlopen((libname = FLUIDSYNTHLIB), RTLD_LAZY); - if (FluidSynthSO == NULL) + if (strlen(fluid_lib) > 0) { - Printf(TEXTCOLOR_RED"Could not load " FLUIDSYNTHLIB ": %s\n", dlerror()); - return false; + FluidSynthSO = dlopen(libname = fluid_lib, RTLD_LAZY); + if (nullptr == FluidSynthSO) + { + Printf(TEXTCOLOR_RED "Could not load %s: %s\n", libname, dlerror()); + } + } + else + { + FluidSynthSO = nullptr; + } + + if (nullptr == FluidSynthSO) + { + FluidSynthSO = dlopen(libname = FLUIDSYNTHLIB, RTLD_LAZY); + if (nullptr == FluidSynthSO) + { + Printf(TEXTCOLOR_RED "Could not load " FLUIDSYNTHLIB ": %s\n", dlerror()); + return false; + } } #endif