Make sure sources are deleted with the context

This commit is contained in:
Chris Robinson
2008-01-16 13:27:15 -08:00
parent bb7b18d4e1
commit 8ad16145f6
3 changed files with 23 additions and 0 deletions
+1
View File
@@ -1013,6 +1013,7 @@ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context)
// Lock context
SuspendContext(context);
ReleaseALSources(context);
ReleaseALAuxiliaryEffectSlots(context);
context->Device->Context = NULL;
+2
View File
@@ -97,6 +97,8 @@ typedef struct ALsource
struct ALsource *next;
} ALsource;
ALvoid ReleaseALSources(ALCcontext *Context);
#ifdef __cplusplus
}
#endif
+20
View File
@@ -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;
}