diff options
author | Chris Robinson <[email protected]> | 2014-01-03 20:21:12 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-01-03 20:21:12 -0800 |
commit | 42a67731c411775fe9de5d3a05edfd10205cc70f (patch) | |
tree | 39dae63b0c7c048e81c1263897c68a55d7685fa6 /Alc/ALc.c | |
parent | 3a31402b1ea3cb62da6ddcac3f41570c7cfaa687 (diff) |
Add storage for a default soundfont object
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 51 |
1 files changed, 51 insertions, 0 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); |