diff options
-rw-r--r-- | Alc/ALc.c | 51 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 3 | ||||
-rw-r--r-- | OpenAL32/Include/alMidi.h | 1 | ||||
-rw-r--r-- | OpenAL32/alFontsound.c | 4 | ||||
-rw-r--r-- | OpenAL32/alPreset.c | 4 |
5 files changed, 59 insertions, 4 deletions
@@ -1949,6 +1949,57 @@ static ALCvoid FreeDevice(ALCdevice *device) DELETE_OBJ(state); } + if(device->DefaultSfont) + { + ALsoundfont *sfont = device->DefaultSfont; + ALsfpreset **presets; + ALsizei num_presets; + ALsizei i; + + presets = ExchangePtr((XchgPtr*)&sfont->Presets, NULL); + num_presets = ExchangeInt(&sfont->NumPresets, 0); + + for(i = 0;i < num_presets;i++) + { + ALsfpreset *preset = presets[i]; + ALfontsound **sounds; + ALsizei num_sounds; + ALboolean deleting; + ALsizei j; + + sounds = ExchangePtr((XchgPtr*)&preset->Sounds, NULL); + num_sounds = ExchangeInt(&preset->NumSounds, 0); + DeletePreset(preset, device); + preset = NULL; + + for(j = 0;j < num_sounds;j++) + DecrementRef(&sounds[j]->ref); + /* Some fontsounds may not be immediately deletable because they're + * linked to another fontsound. When those fontsounds are deleted + * they should become deletable, so use a loop until all fontsounds + * are deleted. */ + do { + deleting = AL_FALSE; + for(j = 0;j < num_sounds;j++) + { + if(sounds[j] && sounds[j]->ref == 0) + { + deleting = AL_TRUE; + RemoveFontsound(device, sounds[j]->id); + ALfontsound_Destruct(sounds[j]); + free(sounds[j]); + sounds[j] = NULL; + } + } + } while(deleting); + free(sounds); + } + + ALsoundfont_Destruct(sfont); + free(sfont); + } + device->DefaultSfont = NULL; + if(device->BufferMap.size > 0) { WARN("(%p) Deleting %d Buffer(s)\n", device, device->BufferMap.size); diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index b4966028..cf843919 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -545,6 +545,9 @@ struct ALCdevice_struct // Map of Fontsounds for this device UIntMap FontsoundMap; + /* Default soundfont (accessible as ID 0) */ + struct ALsoundfont *DefaultSfont; + /* MIDI synth engine */ struct MidiSynth *Synth; diff --git a/OpenAL32/Include/alMidi.h b/OpenAL32/Include/alMidi.h index e452a732..998f6e92 100644 --- a/OpenAL32/Include/alMidi.h +++ b/OpenAL32/Include/alMidi.h @@ -94,6 +94,7 @@ typedef struct ALfontsound { ALuint id; } ALfontsound; +void ALfontsound_Destruct(ALfontsound *self); void ALfontsound_setPropi(ALfontsound *self, ALCcontext *context, ALenum param, ALint value); ALfontsound *NewFontsound(ALCcontext *context); diff --git a/OpenAL32/alFontsound.c b/OpenAL32/alFontsound.c index 4ec74ebc..540f726b 100644 --- a/OpenAL32/alFontsound.c +++ b/OpenAL32/alFontsound.c @@ -16,7 +16,7 @@ extern inline struct ALfontsound *LookupFontsound(ALCdevice *device, ALuint id); extern inline struct ALfontsound *RemoveFontsound(ALCdevice *device, ALuint id); static void ALfontsound_Construct(ALfontsound *self); -static void ALfontsound_Destruct(ALfontsound *self); +void ALfontsound_Destruct(ALfontsound *self); void ALfontsound_setPropi(ALfontsound *self, ALCcontext *context, ALenum param, ALint value); @@ -541,7 +541,7 @@ static void ALfontsound_Construct(ALfontsound *self) self->id = 0; } -static void ALfontsound_Destruct(ALfontsound *self) +void ALfontsound_Destruct(ALfontsound *self) { ALsizei i; diff --git a/OpenAL32/alPreset.c b/OpenAL32/alPreset.c index 976e45f9..4188bf6c 100644 --- a/OpenAL32/alPreset.c +++ b/OpenAL32/alPreset.c @@ -16,7 +16,7 @@ extern inline struct ALsfpreset *LookupPreset(ALCdevice *device, ALuint id); extern inline struct ALsfpreset *RemovePreset(ALCdevice *device, ALuint id); static void ALsfpreset_Construct(ALsfpreset *self); -static void ALsfpreset_Destruct(ALsfpreset *self); +void ALsfpreset_Destruct(ALsfpreset *self); AL_API void AL_APIENTRY alGenPresetsSOFT(ALsizei n, ALuint *ids) @@ -307,7 +307,7 @@ static void ALsfpreset_Construct(ALsfpreset *self) self->id = 0; } -static void ALsfpreset_Destruct(ALsfpreset *self) +void ALsfpreset_Destruct(ALsfpreset *self) { ALsizei i; |