backport default/2.0 commits 6c6adcc and 1e215d1 for fluidsynth support: SDL-1.2
authorOzkan Sezer
Sat, 14 Dec 2019 18:14:10 +0300
branchSDL-1.2
changeset 1081119300487b73
parent 1080 dcccb70e568f
child 1082 83da6758753b
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
music.c
     1.1 --- a/mixer.c	Sat Dec 14 18:12:10 2019 +0300
     1.2 +++ b/mixer.c	Sat Dec 14 18:14:10 2019 +0300
     1.3 @@ -107,9 +107,7 @@
     1.4  static int num_decoders = 0;
     1.5  
     1.6  /* Semicolon-separated SoundFont paths */
     1.7 -#ifdef MID_MUSIC
     1.8  extern char* soundfont_paths;
     1.9 -#endif
    1.10  
    1.11  int Mix_GetNumChunkDecoders(void)
    1.12  {
    1.13 @@ -148,6 +146,11 @@
    1.14  {
    1.15  	int result = 0;
    1.16  
    1.17 +#ifdef MIX_INIT_SOUNDFONT_PATHS
    1.18 +	if (!soundfont_paths)
    1.19 +		soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS);
    1.20 +#endif
    1.21 +
    1.22  	if (flags & MIX_INIT_FLUIDSYNTH) {
    1.23  #ifdef USE_FLUIDSYNTH_MIDI
    1.24  		if ((initialized & MIX_INIT_FLUIDSYNTH) || Mix_InitFluidSynth() == 0) {
    1.25 @@ -227,12 +230,10 @@
    1.26  		Mix_QuitOgg();
    1.27  	}
    1.28  #endif
    1.29 -#ifdef MID_MUSIC
    1.30  	if (soundfont_paths) {
    1.31  		SDL_free(soundfont_paths);
    1.32  		soundfont_paths=NULL;
    1.33  	}
    1.34 -#endif
    1.35  	initialized = 0;
    1.36  }
    1.37  
     2.1 --- a/music.c	Sat Dec 14 18:12:10 2019 +0300
     2.2 +++ b/music.c	Sat Dec 14 18:14:10 2019 +0300
     2.3 @@ -145,9 +145,7 @@
     2.4  static int num_decoders = 0;
     2.5  
     2.6  /* Semicolon-separated SoundFont paths */
     2.7 -#ifdef MID_MUSIC
     2.8  char* soundfont_paths = NULL;
     2.9 -#endif
    2.10  
    2.11  int Mix_GetNumMusicDecoders(void)
    2.12  {
    2.13 @@ -1527,7 +1525,6 @@
    2.14  
    2.15  int Mix_SetSoundFonts(const char *paths)
    2.16  {
    2.17 -#ifdef MID_MUSIC
    2.18  	if (soundfont_paths) {
    2.19  		SDL_free(soundfont_paths);
    2.20  		soundfont_paths = NULL;
    2.21 @@ -1539,26 +1536,24 @@
    2.22  			return 0;
    2.23  		}
    2.24  	}
    2.25 -#endif
    2.26  	return 1;
    2.27  }
    2.28  
    2.29 -#ifdef MID_MUSIC
    2.30  const char* Mix_GetSoundFonts(void)
    2.31  {
    2.32  	const char* force = getenv("SDL_FORCE_SOUNDFONTS");
    2.33  
    2.34  	if (!soundfont_paths || (force && force[0] == '1')) {
    2.35  		return getenv("SDL_SOUNDFONTS");
    2.36 -	} else {
    2.37 -		return soundfont_paths;
    2.38  	}
    2.39 +	return soundfont_paths;
    2.40  }
    2.41  
    2.42  int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data)
    2.43  {
    2.44  	char *context, *path, *paths;
    2.45  	const char* cpaths = Mix_GetSoundFonts();
    2.46 +	int soundfonts_found = 0;
    2.47  
    2.48  	if (!cpaths) {
    2.49  		Mix_SetError("No SoundFonts have been requested");
    2.50 @@ -1578,12 +1573,11 @@
    2.51  	for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) {
    2.52  #endif
    2.53  		if (!function(path, data)) {
    2.54 -			SDL_free(paths);
    2.55 -			return 0;
    2.56 +			continue;
    2.57  		}
    2.58 +		soundfonts_found++;
    2.59  	}
    2.60  
    2.61  	SDL_free(paths);
    2.62 -	return 1;
    2.63 +	return (soundfonts_found > 0);
    2.64  }
    2.65 -#endif