From 8ad16145f69d36d2de6b9d0a032479ca71ff4a67 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Jan 2008 13:27:15 -0800 Subject: [PATCH] Make sure sources are deleted with the context --- Alc/ALc.c | 1 + OpenAL32/Include/alSource.h | 2 ++ OpenAL32/alSource.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/Alc/ALc.c b/Alc/ALc.c index 5635c87f..2727aa33 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -1013,6 +1013,7 @@ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context) // Lock context SuspendContext(context); + ReleaseALSources(context); ReleaseALAuxiliaryEffectSlots(context); context->Device->Context = NULL; diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index f6a4619a..c0e829ae 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -97,6 +97,8 @@ typedef struct ALsource struct ALsource *next; } ALsource; +ALvoid ReleaseALSources(ALCcontext *Context); + #ifdef __cplusplus } #endif diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index f0ac5847..13cca8e3 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -2272,3 +2272,23 @@ static ALint GetByteOffset(ALsource *pSource) return lByteOffset; } + + +ALvoid ReleaseALSources(ALCcontext *Context) +{ +#ifdef _DEBUG + if(Context->SourceCount > 0) + AL_PRINT("exit() %d Source(s) NOT deleted\n", Context->SourceCount); +#endif + + while(Context->Source) + { + ALsource *temp = Context->Source; + Context->Source = Context->Source->next; + + // Release source structure + memset(temp, 0, sizeof(ALsource)); + free(temp); + } + Context->SourceCount = 0; +} -- 2.11.4.GIT