Added check for patch set existence before loading in FluidSynth

This helps to avoid flooding of output with the following messages on every MIDI song change:
fluidsynth: error: Unable to open file "/usr/share/sounds/sf2/FluidR3_GS.sf2"
fluidsynth: error: Couldn't load soundfont file
fluidsynth: error: Failed to load SoundFont "/usr/share/sounds/sf2/FluidR3_GS.sf2"
fluidsynth: error: Unable to open file "/usr/share/sounds/sf2/FluidR3_GM.sf2"
fluidsynth: error: Couldn't load soundfont file
fluidsynth: error: Failed to load SoundFont "/usr/share/sounds/sf2/FluidR3_GM.sf2"
This commit is contained in:
alexey.lysiuk 2017-05-13 17:56:26 +03:00
parent 1cd7297cd8
commit f0d40d6a8a
1 changed files with 11 additions and 4 deletions

View File

@ -526,14 +526,21 @@ int FluidSynthMIDIDevice::LoadPatchSets(const char *patches)
{ {
path = NicePath(tok); path = NicePath(tok);
} }
if (FLUID_FAILED != fluid_synth_sfload(FluidSynth, path, count == 0)) if (FileExists(path))
{ {
DPrintf(DMSG_NOTIFY, "Loaded patch set %s.\n", tok); if (FLUID_FAILED != fluid_synth_sfload(FluidSynth, path, count == 0))
count++; {
DPrintf(DMSG_NOTIFY, "Loaded patch set %s.\n", tok);
count++;
}
else
{
DPrintf(DMSG_ERROR, "Failed to load patch set %s.\n", tok);
}
} }
else else
{ {
DPrintf(DMSG_ERROR, "Failed to load patch set %s.\n", tok); DPrintf(DMSG_ERROR, "Could not find patch set %s.\n", tok);
} }
tok = strtok(NULL, delim); tok = strtok(NULL, delim);
} }