fall back to Native/SDL on error (#443)

* fall back to Native/SDL on error

* show message box on soundfont loading error
This commit is contained in:
Fabian Greffrath 2022-02-07 09:32:01 +01:00 committed by GitHub
parent abcc96c905
commit b755013f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -23,6 +23,7 @@
#include "doomtype.h"
#include "i_system.h"
#include "i_sound.h"
#include "m_misc2.h"
#include "memio.h"
#include "mus2mid.h"
@ -77,9 +78,14 @@ static boolean I_FL_InitMusic(void)
if (sf_id == FLUID_FAILED)
{
char *errmsg;
delete_fluid_synth(synth);
delete_fluid_settings(settings);
I_Error("Error loading FluidSynth soundfont: %s\n", soundfont_path);
errmsg = M_StringJoin("Error loading FluidSynth soundfont: ",
soundfont_path, NULL);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING,
PROJECT_STRING, errmsg, NULL);
(free)(errmsg);
return false;
}

View File

@ -760,8 +760,17 @@ void I_InitSound(void)
if (midi_player_module)
{
active_module = midi_player_module;
active_module->I_InitMusic();
I_AtExit(active_module->I_ShutdownMusic, true);
if (active_module->I_InitMusic())
{
I_AtExit(active_module->I_ShutdownMusic, true);
}
else
{
// fall back to Native/SDL on error
midi_player = 0;
midi_player_module = NULL;
active_module = &music_sdl_module;
}
}
}
}