fix: gus emulation not falling back to fluidsynth when no patches are found and a valid dmxgus lump is provided

If we load the instruments config without patches the gus emulation will not fall back to fluidsynth and no music will play.
How to replicate the issue:
1. set midi_dmxgus=true
2. select Gus Emulation as midi device
3. remove any path from section SoundfontSearch.Directories (we prevent auto selection of patches)
4. ULTRADIR and gus_patchdir should not be present
This commit is contained in:
Emanuele Disco 2023-01-23 10:12:01 +09:00
parent 75d2994b4b
commit f452fb3e35

View file

@ -97,6 +97,7 @@ void TimidityMIDIDevice::LoadInstruments()
if (gusConfig.reader)
{
// Check if we got some GUS data before using it.
bool prepareInstruments = gusConfig.readerName == "DMXGUS" ? false : true;
std::string ultradir;
const char *ret = getenv("ULTRADIR");
if (ret) ultradir = std::string(ret);
@ -105,12 +106,20 @@ void TimidityMIDIDevice::LoadInstruments()
{
ultradir += "/midi";
gusConfig.reader->add_search_path(ultradir.c_str());
prepareInstruments = true;
}
// Load DMXGUS lump and patches from gus_patchdir
if (gusConfig.gus_patchdir.length() != 0) gusConfig.reader->add_search_path(gusConfig.gus_patchdir.c_str());
if (gusConfig.gus_patchdir.length() != 0)
{
gusConfig.reader->add_search_path(gusConfig.gus_patchdir.c_str());
prepareInstruments = true;
}
gusConfig.instruments.reset(new Timidity::Instruments(gusConfig.reader));
gusConfig.loadedConfig = gusConfig.readerName;
if (prepareInstruments)
{
gusConfig.instruments.reset(new Timidity::Instruments(gusConfig.reader));
gusConfig.loadedConfig = gusConfig.readerName;
}
}
if (gusConfig.instruments == nullptr)
@ -256,8 +265,6 @@ void TimidityMIDIDevice::ComputeOutput(float *buffer, int len)
bool GUS_SetupConfig(const char* args)
{
if (*args == 0) args = gusConfig.gus_config.c_str();
if (gusConfig.gus_dmxgus && *args == 0) args = "DMXGUS";
//if (stricmp(gusConfig.loadedConfig.c_str(), args) == 0) return false; // aleady loaded
MusicIO::SoundFontReaderInterface* reader = MusicIO::ClientOpenSoundFont(args, SF_GUS);
if (!reader && MusicIO::fileExists(args))
@ -277,6 +284,7 @@ bool GUS_SetupConfig(const char* args)
if (!reader && gusConfig.gus_dmxgus)
{
args = "DMXGUS";
reader = new MusicIO::FileSystemSoundFontReader(args, true);
}