aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/midi/fluidsynth.c
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/midi/fluidsynth.c')
-rw-r--r--Alc/midi/fluidsynth.c20
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;