SHA256
1
0
forked from pool/scummvm
scummvm/0005-FLUIDSYNTH-Simplify-FluidSynth-version-check.patch

67 lines
2.8 KiB
Diff
Raw Normal View History

From 631b13b5f4990b667e19d9fbdc467f0c873b6c15 Mon Sep 17 00:00:00 2001
From: Le Philousophe <lephilousophe@users.noreply.github.com>
Date: Mon, 5 Apr 2021 12:22:51 +0200
Subject: [PATCH] FLUIDSYNTH: Simplify FluidSynth version check
---
audio/softsynth/fluidsynth.cpp | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/audio/softsynth/fluidsynth.cpp b/audio/softsynth/fluidsynth.cpp
index 3b9f55346437..e770fb68543b 100644
--- a/audio/softsynth/fluidsynth.cpp
+++ b/audio/softsynth/fluidsynth.cpp
@@ -46,7 +46,15 @@
#include "backends/platform/ios7/ios7_common.h"
#endif
-#if defined(FLUIDSYNTH_VERSION_MAJOR) && FLUIDSYNTH_VERSION_MAJOR > 1
+// 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
+
+#if FS_API_VERSION >= 0x0200
static void logHandler(int level, const char *message, void *data)
#else
static void logHandler(int level, char *message, void *data)
@@ -103,7 +111,7 @@ class MidiDriver_FluidSynth : public MidiDriver_Emulated {
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;
@@ -162,7 +170,7 @@ void MidiDriver_FluidSynth::setStr(const char *name, const char *val) {
// 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] != '&') {
@@ -200,7 +208,7 @@ int MidiDriver_FluidSynth::open() {
fluid_set_log_function(FLUID_INFO, logHandler, NULL);
fluid_set_log_function(FLUID_DBG, logHandler, NULL);
-#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");
@@ -280,7 +288,7 @@ int MidiDriver_FluidSynth::open() {
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,