diff options
-rw-r--r-- | Alc/ALc.c | 11 | ||||
-rw-r--r-- | OpenAL32/Include/alMidi.h | 1 | ||||
-rw-r--r-- | OpenAL32/alMidi.c | 21 |
3 files changed, 33 insertions, 0 deletions
@@ -35,6 +35,7 @@ #include "alBuffer.h" #include "alAuxEffectSlot.h" #include "alError.h" +#include "alMidi.h" #include "bs2b.h" #include "alu.h" @@ -1948,6 +1949,13 @@ static ALCvoid FreeDevice(ALCdevice *device) } ResetUIntMap(&device->FilterMap); + if(device->SfontMap.size > 0) + { + WARN("(%p) Deleting %d Soundfont(s)\n", device, device->SfontMap.size); + ReleaseALSoundfonts(device); + } + ResetUIntMap(&device->SfontMap); + free(device->Bs2b); device->Bs2b = NULL; @@ -2884,6 +2892,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) InitUIntMap(&device->BufferMap, ~0); InitUIntMap(&device->EffectMap, ~0); InitUIntMap(&device->FilterMap, ~0); + InitUIntMap(&device->SfontMap, ~0); //Set output format device->FmtChans = DevFmtChannelsDefault; @@ -3168,6 +3177,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, InitUIntMap(&device->BufferMap, ~0); InitUIntMap(&device->EffectMap, ~0); InitUIntMap(&device->FilterMap, ~0); + InitUIntMap(&device->SfontMap, ~0); device->DeviceName = NULL; @@ -3345,6 +3355,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN InitUIntMap(&device->BufferMap, ~0); InitUIntMap(&device->EffectMap, ~0); InitUIntMap(&device->FilterMap, ~0); + InitUIntMap(&device->SfontMap, ~0); factory = ALCloopbackFactory_getFactory(); device->Backend = V(factory,createBackend)(device, ALCbackend_Loopback); diff --git a/OpenAL32/Include/alMidi.h b/OpenAL32/Include/alMidi.h index 46dcaad5..6cc13b20 100644 --- a/OpenAL32/Include/alMidi.h +++ b/OpenAL32/Include/alMidi.h @@ -112,6 +112,7 @@ inline struct ALsoundfont *LookupSfont(ALCdevice *device, ALuint id) inline struct ALsoundfont *RemoveSfont(ALCdevice *device, ALuint id) { return (struct ALsoundfont*)RemoveUIntMapKey(&device->SfontMap, id); } +void ReleaseALSoundfonts(ALCdevice *device); #ifdef __cplusplus } diff --git a/OpenAL32/alMidi.c b/OpenAL32/alMidi.c index b311d390..c67ef81d 100644 --- a/OpenAL32/alMidi.c +++ b/OpenAL32/alMidi.c @@ -316,3 +316,24 @@ AL_API void AL_APIENTRY alMidiGainSOFT(ALfloat value) done: ALCcontext_DecRef(context); } + + +/* ReleaseALSoundfonts + * + * Called to destroy any soundfonts that still exist on the device + */ +void ReleaseALSoundfonts(ALCdevice *device) +{ + ALsizei i; + for(i = 0;i < device->SfontMap.size;i++) + { + ALsoundfont *temp = device->SfontMap.array[i].value; + device->SfontMap.array[i].value = NULL; + + FreeThunkEntry(temp->id); + ALsoundfont_Destruct(temp); + + memset(temp, 0, sizeof(*temp)); + free(temp); + } +} |