diff options
author | Chris Robinson <[email protected]> | 2013-12-29 05:58:40 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-12-29 05:58:40 -0800 |
commit | 396a2f1595b5296af9f23e115fa02090c0f43353 (patch) | |
tree | ac851b08e29e70c51b9be23b4b6574ecd6311a1d /Alc | |
parent | 7640c658ee7c5ed75a781da692189fb206f59d64 (diff) |
Don't destroy the fluid_sfont_t if any of its samples are still playing
FluidSynth apparently doesn't check for this itself before calling the free
callback.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/midi/fluidsynth.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Alc/midi/fluidsynth.c b/Alc/midi/fluidsynth.c index 697a95c8..ec4a7345 100644 --- a/Alc/midi/fluidsynth.c +++ b/Alc/midi/fluidsynth.c @@ -129,6 +129,18 @@ static void FPreset_Destruct(FPreset *self) self->NumSamples = 0; } +static ALboolean FPreset_canDelete(FPreset *self) +{ + ALsizei i; + + for(i = 0;i < self->NumSamples;i++) + { + if(fluid_sample_refcount(STATIC_CAST(fluid_sample_t, &self->Samples[i])) != 0) + return AL_FALSE; + } + return AL_TRUE; +} + static char* FPreset_getName(fluid_preset_t *preset) { return ((FPreset*)preset->data)->Name; @@ -265,6 +277,14 @@ static void FSfont_Destruct(FSfont *self) static int FSfont_free(fluid_sfont_t *sfont) { FSfont *self = STATIC_UPCAST(FSfont, fluid_sfont_t, sfont); + ALsizei i; + + for(i = 0;i < self->NumPresets;i++) + { + if(!FPreset_canDelete(&self->Presets[i])) + return 1; + } + FSfont_Destruct(self); free(self); return 0; |