diff options
author | Chris Robinson <[email protected]> | 2013-11-28 05:30:48 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-11-28 05:30:48 -0800 |
commit | f4cf84e72d43bef6256095c177457a5edb441a58 (patch) | |
tree | 80483e0d1b9ab69dd91df427c13af21d272db122 /OpenAL32 | |
parent | 8615a109ce436bcd99a10596c20e50830ea97f4c (diff) |
Combine duplicate soundfont loading code
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alMidi.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/OpenAL32/alMidi.c b/OpenAL32/alMidi.c index abfb7fd1..b15823c0 100644 --- a/OpenAL32/alMidi.c +++ b/OpenAL32/alMidi.c @@ -190,6 +190,14 @@ static ALenum FSynth_loadSoundfont(FSynth *self, const char *filename) { int fontid; + if(!filename || !filename[0]) + filename = GetConfigValue("midi", "soundfont", ""); + if(!filename[0]) + { + ERR("No default soundfont found!\n"); + return AL_INVALID_VALUE; + } + fontid = fluid_synth_sfload(self->Synth, filename, 1); if(fontid == FLUID_FAILED) { @@ -206,21 +214,9 @@ static ALenum FSynth_loadSoundfont(FSynth *self, const char *filename) static void FSynth_setState(FSynth *self, ALenum state) { - if(state == AL_PLAYING) - { - if(self->FontID == FLUID_FAILED) - { - const char *filename = GetConfigValue("midi", "soundfont", ""); - if(!filename[0]) - ERR("No default soundfont found!\n"); - else - { - self->FontID = fluid_synth_sfload(self->Synth, filename, 1); - if(self->FontID == FLUID_FAILED) - ERR("Failed to load soundfont '%s'\n", filename); - } - } - } + if(state == AL_PLAYING && self->FontID == FLUID_FAILED) + FSynth_loadSoundfont(self, NULL); + MidiSynth_setState(STATIC_CAST(MidiSynth, self), state); } |