Navigation Menu

Skip to content

Commit

Permalink
backport default/2.0 commits 6c6adcc and 1e215d1 for fluidsynth support:
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
sezero committed Dec 14, 2019
1 parent e78e3fb commit 50432a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
9 changes: 5 additions & 4 deletions mixer.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
16 changes: 5 additions & 11 deletions music.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -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

0 comments on commit 50432a0

Please sign in to comment.