From 50432a0e0209767f533406d6925bcbb8c3e6c46c Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sat, 14 Dec 2019 18:14:10 +0300 Subject: [PATCH] backport default/2.0 commits 6c6adcc and 1e215d1 for fluidsynth support: - soundfont API functions are public and should always be available (bugs 3071 and 3088) - no sf2 sound fonts loaded by default (http://bugs.debian.org/715461) --- mixer.c | 9 +++++---- music.c | 16 +++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mixer.c b/mixer.c index 1f01d019..c653d6ed 100644 --- a/mixer.c +++ b/mixer.c @@ -107,9 +107,7 @@ static const char **chunk_decoders = NULL; static int num_decoders = 0; /* Semicolon-separated SoundFont paths */ -#ifdef MID_MUSIC extern char* soundfont_paths; -#endif int Mix_GetNumChunkDecoders(void) { @@ -148,6 +146,11 @@ int Mix_Init(int flags) { int result = 0; +#ifdef MIX_INIT_SOUNDFONT_PATHS + if (!soundfont_paths) + soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS); +#endif + if (flags & MIX_INIT_FLUIDSYNTH) { #ifdef USE_FLUIDSYNTH_MIDI if ((initialized & MIX_INIT_FLUIDSYNTH) || Mix_InitFluidSynth() == 0) { @@ -227,12 +230,10 @@ void Mix_Quit(void) Mix_QuitOgg(); } #endif -#ifdef MID_MUSIC if (soundfont_paths) { SDL_free(soundfont_paths); soundfont_paths=NULL; } -#endif initialized = 0; } diff --git a/music.c b/music.c index 1ad15d32..f0a5fa33 100644 --- a/music.c +++ b/music.c @@ -145,9 +145,7 @@ static const char **music_decoders = NULL; static int num_decoders = 0; /* Semicolon-separated SoundFont paths */ -#ifdef MID_MUSIC char* soundfont_paths = NULL; -#endif int Mix_GetNumMusicDecoders(void) { @@ -1527,7 +1525,6 @@ void close_music(void) int Mix_SetSoundFonts(const char *paths) { -#ifdef MID_MUSIC if (soundfont_paths) { SDL_free(soundfont_paths); soundfont_paths = NULL; @@ -1539,26 +1536,24 @@ int Mix_SetSoundFonts(const char *paths) return 0; } } -#endif return 1; } -#ifdef MID_MUSIC const char* Mix_GetSoundFonts(void) { const char* force = getenv("SDL_FORCE_SOUNDFONTS"); if (!soundfont_paths || (force && force[0] == '1')) { return getenv("SDL_SOUNDFONTS"); - } else { - return soundfont_paths; } + return soundfont_paths; } int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data) { char *context, *path, *paths; const char* cpaths = Mix_GetSoundFonts(); + int soundfonts_found = 0; if (!cpaths) { Mix_SetError("No SoundFonts have been requested"); @@ -1578,12 +1573,11 @@ int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data) for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) { #endif if (!function(path, data)) { - SDL_free(paths); - return 0; + continue; } + soundfonts_found++; } SDL_free(paths); - return 1; + return (soundfonts_found > 0); } -#endif