shithub: choc

Download patch

ref: 74aa9078ec06b207ac7b41078f7d2cceb9b385f4
parent: 54fd5795e6139328fdc1e2459f9134423b10f421
author: Roman Fomin <rfomin@gmail.com>
date: Sat Nov 13 04:51:01 EST 2021

Add a check for the existence of a soundfont file

--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -185,6 +185,8 @@
 // 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.
 
@@ -226,6 +228,18 @@
 
     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 @@
 #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();
     }