Make sure sources are deleted with the context
This commit is contained in:
@@ -1013,6 +1013,7 @@ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context)
|
||||
// Lock context
|
||||
SuspendContext(context);
|
||||
|
||||
ReleaseALSources(context);
|
||||
ReleaseALAuxiliaryEffectSlots(context);
|
||||
|
||||
context->Device->Context = NULL;
|
||||
|
||||
@@ -97,6 +97,8 @@ typedef struct ALsource
|
||||
struct ALsource *next;
|
||||
} ALsource;
|
||||
|
||||
ALvoid ReleaseALSources(ALCcontext *Context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user