aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alSource.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-10-24 07:09:44 -0700
committerChris Robinson <[email protected]>2009-10-24 07:09:44 -0700
commitbbccf76b4584eca741867f9a6ed89abe1bf48a85 (patch)
tree09bbeb3ee8f700e24f7c5fd0be928d5e757f1d20 /OpenAL32/alSource.c
parent1f47fa92432a51625e87e45229534b47ff40897c (diff)
Dereference left over buffers and slots when sources are released
Diffstat (limited to 'OpenAL32/alSource.c')
-rw-r--r--OpenAL32/alSource.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 6d5e1dd9..d339d061 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -2150,10 +2150,31 @@ static ALint GetByteOffset(ALsource *pSource)
ALvoid ReleaseALSources(ALCcontext *Context)
{
+ ALuint j;
+
while(Context->Source)
{
ALsource *temp = Context->Source;
- Context->Source = Context->Source->next;
+ Context->Source = temp->next;
+
+ // For each buffer in the source's queue, decrement its reference counter and remove it
+ while(temp->queue != NULL)
+ {
+ ALbufferlistitem *ALBufferList = temp->queue;
+ // Decrement buffer's reference counter
+ if(ALBufferList->buffer != NULL)
+ ALBufferList->buffer->refcount--;
+ // Update queue to point to next element in list
+ temp->queue = ALBufferList->next;
+ // Release memory allocated for buffer list item
+ free(ALBufferList);
+ }
+
+ for(j = 0;j < MAX_SENDS;++j)
+ {
+ if(temp->Send[j].Slot)
+ temp->Send[j].Slot->refcount--;
+ }
// Release source structure
ALTHUNK_REMOVEENTRY(temp->source);