From f0d40d6a8aaa772e3b6d0e9b0f5f3dc0175efdcc Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 13 May 2017 17:56:26 +0300 Subject: [PATCH] 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" --- .../mididevices/music_fluidsynth_mididevice.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sound/mididevices/music_fluidsynth_mididevice.cpp b/src/sound/mididevices/music_fluidsynth_mididevice.cpp index 38c8eed22..07102c43d 100644 --- a/src/sound/mididevices/music_fluidsynth_mididevice.cpp +++ b/src/sound/mididevices/music_fluidsynth_mididevice.cpp @@ -526,14 +526,21 @@ int FluidSynthMIDIDevice::LoadPatchSets(const char *patches) { 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); - count++; + if (FLUID_FAILED != fluid_synth_sfload(FluidSynth, path, count == 0)) + { + DPrintf(DMSG_NOTIFY, "Loaded patch set %s.\n", tok); + count++; + } + else + { + DPrintf(DMSG_ERROR, "Failed to load patch set %s.\n", tok); + } } 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); }