Backported from 631b13b5f4990b667e19d9fbdc467f0c873b6c15 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Mon, 5 Apr 2021 12:22:51 +0200 Subject: FLUIDSYNTH: Simplify FluidSynth version check --- scummvm-2.2.0-orig/audio/softsynth/fluidsynth.cpp +++ scummvm-2.2.0/audio/softsynth/fluidsynth.cpp @@ -46,6 +46,14 @@ #include "backends/platform/ios7/ios7_common.h" #endif +// We assume here Fluidsynth minor will never be above 255 and +// that micro versions won't break API compatibility +#if defined(FLUIDSYNTH_VERSION_MAJOR) && defined(FLUIDSYNTH_VERSION_MINOR) +#define FS_API_VERSION ((FLUIDSYNTH_VERSION_MAJOR << 8) | FLUIDSYNTH_VERSION_MINOR) +#else +#define FS_API_VERSION 0 +#endif + class MidiDriver_FluidSynth : public MidiDriver_Emulated { private: MidiChannel_MPU401 _midiChannels[16]; @@ -75,7 +83,7 @@ void setEngineSoundFont(Common::SeekableReadStream *soundFontData) override; bool acceptsSoundFontData() override { -#if defined(FLUIDSYNTH_VERSION_MAJOR) && FLUIDSYNTH_VERSION_MAJOR > 1 +#if FS_API_VERSION >= 0x0200 return true; #else return false; @@ -134,7 +142,7 @@ // Soundfont memory loader callback functions. -#if defined(FLUIDSYNTH_VERSION_MAJOR) && FLUIDSYNTH_VERSION_MAJOR > 1 +#if FS_API_VERSION >= 0x0200 static void *SoundFontMemLoader_open(const char *filename) { void *p; if (filename[0] != '&') { @@ -166,7 +174,7 @@ if (_isOpen) return MERR_ALREADY_OPEN; -#if defined(FLUIDSYNTH_VERSION_MAJOR) && FLUIDSYNTH_VERSION_MAJOR > 1 +#if FS_API_VERSION >= 0x0200 // When provided with in-memory SoundFont data, only use the configured // SoundFont instead if it's explicitly configured on the current game. bool isUsingInMemorySoundFontData = _engineSoundFontData && !ConfMan.getActiveDomain()->contains("soundfont"); @@ -246,7 +254,7 @@ const char *soundfont = !isUsingInMemorySoundFontData ? ConfMan.get("soundfont").c_str() : Common::String::format("&%p", (void *)_engineSoundFontData).c_str(); -#if defined(FLUIDSYNTH_VERSION_MAJOR) && FLUIDSYNTH_VERSION_MAJOR > 1 +#if FS_API_VERSION >= 0x0200 if (isUsingInMemorySoundFontData) { fluid_sfloader_t *soundFontMemoryLoader = new_fluid_defsfloader(_settings); fluid_sfloader_set_callbacks(soundFontMemoryLoader,