scummvm/0005-FLUIDSYNTH-Simplify-FluidSynth-version-check.patch
Ferdinand Thiessen 1499fe8af5 Accepting request 886072 from home:alarrosa:branches:games
- Add patches from upstream to fix build with fluidsynth 2.2
  * 0001-FLUIDSYNTH-Make-FluidSynth-logging-less-noisy-by-default.patch
  * 0002-FLUIDSYNTH-Swapped-debug-levels-for-FLUID_WARN-and-FLUID_INFO.patch
  * 0003-FLUIDSYNTH-Fix-build.patch
  * 0004-AUDIO-Fix-compilation-with-Fluidsynth2.patch
  * 0005-FLUIDSYNTH-Simplify-FluidSynth-version-check.patch
  * 0006-FLUIDSYNTH-Fix-compilation-with-Fluidsynth-2.2.patch

OBS-URL: https://build.opensuse.org/request/show/886072
OBS-URL: https://build.opensuse.org/package/show/games/scummvm?expand=0&rev=65
2021-04-16 19:01:31 +00:00

67 lines
2.8 KiB
Diff

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,