diff options
author | Chris Robinson <[email protected]> | 2014-01-04 05:30:57 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-01-04 05:30:57 -0800 |
commit | 540a99e71fa4ce3de8049656629861aa0a7e5568 (patch) | |
tree | 34651c72d9c31bb5a86f9506bfc301d84897c239 /OpenAL32 | |
parent | bb54743425c92856347c8c3f04ac07e319ff0fcd (diff) |
Allow "deleting" the default soundfont
The ID remains valid and the soundfont will be reloaded as needed, but this
provides a way for the application to clear up the soundfont memory.
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alSoundfont.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/OpenAL32/alSoundfont.c b/OpenAL32/alSoundfont.c index 60a18ea5..04b5e525 100644 --- a/OpenAL32/alSoundfont.c +++ b/OpenAL32/alSoundfont.c @@ -76,11 +76,13 @@ AL_API ALvoid AL_APIENTRY alDeleteSoundfontsSOFT(ALsizei n, const ALuint *ids) device = context->Device; for(i = 0;i < n;i++) { - if(!ids[i]) - continue; - /* Check for valid soundfont ID */ - if((sfont=LookupSfont(device, ids[i])) == NULL) + if(ids[i] == 0) + { + if(!(sfont=device->DefaultSfont)) + continue; + } + else if((sfont=LookupSfont(device, ids[i])) == NULL) SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done); if(sfont->Mapped != AL_FALSE || sfont->ref != 0) SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done); @@ -88,7 +90,17 @@ AL_API ALvoid AL_APIENTRY alDeleteSoundfontsSOFT(ALsizei n, const ALuint *ids) for(i = 0;i < n;i++) { - if((sfont=RemoveSfont(device, ids[i])) == NULL) + if(ids[i] == 0) + { + MidiSynth *synth = device->Synth; + WriteLock(&synth->Lock); + if(device->DefaultSfont != NULL) + MidiSynth_deleteSoundfont(device, device->DefaultSfont); + device->DefaultSfont = NULL; + WriteUnlock(&synth->Lock); + continue; + } + else if((sfont=RemoveSfont(device, ids[i])) == NULL) continue; ALsoundfont_Destruct(sfont); |