foxygit / doom Log in
commit ed96b0d9a3161421ca4c319e761be8c1afc7bbb8
Author:     Roman Fomin <rfomin@gmail.com>
AuthorDate: Sat Nov 13 00:19:17 2021 +0700
Commit:     Roman Fomin <rfomin@gmail.com>
CommitDate: Sat Nov 13 00:19:17 2021 +0700

    Fix Fluidsynth support for Windows
---
 src/i_sdlmusic.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index 18f6fdc4..4bae48f0 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -185,6 +185,7 @@ 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.

@@ -226,7 +227,15 @@ static boolean I_SDL_InitMusic(void)

     if (strlen(fluidsynth_sf_path) > 0 && strlen(timidity_cfg_path) == 0)
     {
-        Mix_SetSoundFonts(fluidsynth_sf_path);
+        if (!M_FileExists(fluidsynth_sf_path))
+        {
+            fprintf(stderr, "Can't find Fluidsynth soundfont.\n");
+        }
+        else
+        {
+            Mix_SetSoundFonts(fluidsynth_sf_path);
+            fluidsynth_sf_is_set = true;
+        }
     }

     // If snd_musiccmd is set, we need to call Mix_SetMusicCMD to
@@ -238,8 +247,9 @@ static boolean I_SDL_InitMusic(void)
     }

 #if defined(_WIN32)
-    // Don't enable it for GUS, since it handles its own volume just fine.
-    if (snd_musicdevice != SNDDEVICE_GUS)
+    // Don't enable it for GUS or Fluidsynth, since they handle their own volume
+    // just fine.
+    if (snd_musicdevice != SNDDEVICE_GUS && !fluidsynth_sf_is_set)
     {
         win_midi_stream_opened = I_WIN_InitMusic();
     }