From e699ab8614d1806c8961efa02a947d3e25e0bc67 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 31 Dec 2013 00:49:43 -0800 Subject: Force all FluidSynth sounds off when changing soundfonts Selecting soundfonts should only happen when the MIDI engine is stopped or reset. When stopped some notes may be left in a release phase, but we need to ensure all fluid_sample_t objects are finished before unloading since the soundfont (and associated sample memory) may be deleted at any time afterward. --- Alc/midi/fluidsynth.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Alc/midi/fluidsynth.c b/Alc/midi/fluidsynth.c index 25b367af..f5074d6d 100644 --- a/Alc/midi/fluidsynth.c +++ b/Alc/midi/fluidsynth.c @@ -447,6 +447,11 @@ static ALenum FSynth_selectSoundfonts(FSynth *self, ALCdevice *device, ALsizei c ret = MidiSynth_selectSoundfonts(STATIC_CAST(MidiSynth, self), device, count, ids); if(ret != AL_NO_ERROR) return ret; + ALCdevice_Lock(device); + for(i = 0;i < 16;i++) + fluid_synth_all_sounds_off(self->Synth, i); + ALCdevice_Unlock(device); + fontid = malloc(count * sizeof(fontid[0])); if(fontid) { @@ -695,4 +700,4 @@ MidiSynth *FSynth_create(ALCdevice* UNUSED(device)) return NULL; } -#endif \ No newline at end of file +#endif -- cgit v1.2.3