Added ability to customize path to FluidSynth dynamic library

Use fluid_lib CVAR to set path or default name of dynamic library will be used instead
This commit is contained in:
alexey.lysiuk 2016-09-17 16:54:02 +03:00 committed by Christoph Oelckers
parent 4f7e1f0171
commit 0a24c15445

View file

@ -96,6 +96,8 @@
// PUBLIC DATA DEFINITIONS ------------------------------------------------- // PUBLIC DATA DEFINITIONS -------------------------------------------------
CVAR(String, fluid_lib, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(String, fluid_patchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(String, fluid_patchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Float, fluid_gain, 0.5, 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; const char *libname;
#ifdef _WIN32 #ifdef _WIN32
FluidSynthDLL = LoadLibrary((libname = FLUIDSYNTHLIB1)); if (strlen(fluid_lib) > 0)
if (FluidSynthDLL == NULL)
{ {
FluidSynthDLL = LoadLibrary((libname = FLUIDSYNTHLIB2)); FluidSynthDLL = LoadLibrary(libname = fluid_lib);
if (FluidSynthDLL == NULL) if (nullptr == FluidSynthDLL)
{ {
Printf(TEXTCOLOR_RED"Could not load " FLUIDSYNTHLIB1 " or " FLUIDSYNTHLIB2 "\n"); Printf(TEXTCOLOR_RED "Could not load %s\n", libname);
return false; }
}
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 #else
FluidSynthSO = dlopen((libname = FLUIDSYNTHLIB), RTLD_LAZY); if (strlen(fluid_lib) > 0)
if (FluidSynthSO == NULL)
{ {
Printf(TEXTCOLOR_RED"Could not load " FLUIDSYNTHLIB ": %s\n", dlerror()); FluidSynthSO = dlopen(libname = fluid_lib, RTLD_LAZY);
return false; 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 #endif