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.
This commit is contained in:
Chris Robinson
2013-12-31 00:49:43 -08:00
parent 6b2d3c3cfa
commit e699ab8614
+6 -1
View File
@@ -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
#endif