commit 74aa9078ec06b207ac7b41078f7d2cceb9b385f4
Author: Roman Fomin <rfomin@gmail.com>
AuthorDate: Sat Nov 13 09:51:01 2021 +0700
Commit: Roman Fomin <rfomin@gmail.com>
CommitDate: Sat Nov 13 09:51:01 2021 +0700
Add a check for the existence of a soundfont file
---
src/i_sdlmusic.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index 536e98b8..7f1d0c0c 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -185,6 +185,8 @@ static boolean SDLIsInitialized(void)
// Initialize music subsystem
static boolean I_SDL_InitMusic(void)
{
+ boolean fluidsynth_sf_is_set = false;
+
// If SDL_mixer is not initialized, we have to initialize it
// and have the responsibility to shut it down later on.
@@ -225,6 +227,18 @@ static boolean I_SDL_InitMusic(void)
// Mix_SetSoundFonts if necessary.
if (strlen(fluidsynth_sf_path) > 0 && strlen(timidity_cfg_path) == 0)
+ {
+ if (M_FileExists(fluidsynth_sf_path))
+ {
+ fluidsynth_sf_is_set = true;
+ }
+ else
+ {
+ fprintf(stderr, "Can't find Fluidsynth soundfont.\n");
+ }
+ }
+
+ if (fluidsynth_sf_is_set)
{
Mix_SetSoundFonts(fluidsynth_sf_path);
}
@@ -240,7 +254,7 @@ static boolean I_SDL_InitMusic(void)
#if defined(_WIN32)
// Don't enable it for GUS or Fluidsynth, since they handle their own volume
// just fine.
- if (snd_musicdevice != SNDDEVICE_GUS && strlen(fluidsynth_sf_path) == 0)
+ if (snd_musicdevice != SNDDEVICE_GUS && !fluidsynth_sf_is_set)
{
win_midi_stream_opened = I_WIN_InitMusic();
}