aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c13
-rw-r--r--Alc/ALu.c29
2 files changed, 27 insertions, 15 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index dd2b165c..574dce06 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2137,6 +2137,8 @@ static ALvoid InitContext(ALCcontext *Context)
*/
static ALCvoid FreeContext(ALCcontext *context)
{
+ ALsizei i;
+
TRACE("%p\n", context);
if(context->SourceMap.size > 0)
@@ -2153,9 +2155,14 @@ static ALCvoid FreeContext(ALCcontext *context)
}
ResetUIntMap(&context->EffectSlotMap);
- context->ActiveSourceCount = 0;
+ for(i = 0;i < context->MaxActiveSources;i++)
+ {
+ al_free(context->ActiveSources[i]);
+ context->ActiveSources[i] = NULL;
+ }
free(context->ActiveSources);
context->ActiveSources = NULL;
+ context->ActiveSourceCount = 0;
context->MaxActiveSources = 0;
context->ActiveEffectSlotCount = 0;
@@ -2877,8 +2884,8 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ALContext->Listener = (ALlistener*)(((ALintptrEXT)(ALContext+1)+15)&~15);
ALContext->MaxActiveSources = 256;
- ALContext->ActiveSources = malloc(sizeof(ALContext->ActiveSources[0]) *
- ALContext->MaxActiveSources);
+ ALContext->ActiveSources = calloc(ALContext->MaxActiveSources,
+ sizeof(ALContext->ActiveSources[0]));
}
if(!ALContext || !ALContext->ActiveSources)
{
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 5e1965f9..6c92bf5d 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1025,7 +1025,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
{
ALuint SamplesToDo;
ALeffectslot **slot, **slot_end;
- ALsource **src, **src_end;
+ ALactivesource **src, **src_end;
ALCcontext *ctx;
FPUCtl oldMode;
ALuint i, c;
@@ -1058,18 +1058,22 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
src_end = src + ctx->ActiveSourceCount;
while(src != src_end)
{
- if((*src)->state != AL_PLAYING)
+ ALsource *source = (*src)->Source;
+
+ if(source->state != AL_PLAYING)
{
+ ALactivesource *temp = *(--src_end);
+ *src_end = *src;
+ *src = temp;
--(ctx->ActiveSourceCount);
- *src = *(--src_end);
continue;
}
- if(!DeferUpdates && (ExchangeInt(&(*src)->NeedsUpdate, AL_FALSE) ||
+ if(!DeferUpdates && (ExchangeInt(&source->NeedsUpdate, AL_FALSE) ||
UpdateSources))
- ALsource_Update(*src, ctx);
+ ALsource_Update(source, ctx);
- MixSource(*src, device, SamplesToDo);
+ MixSource(source, device, SamplesToDo);
src++;
}
@@ -1233,18 +1237,19 @@ ALvoid aluHandleDisconnect(ALCdevice *device)
Context = device->ContextList;
while(Context)
{
- ALsource **src, **src_end;
+ ALactivesource **src, **src_end;
src = Context->ActiveSources;
src_end = src + Context->ActiveSourceCount;
while(src != src_end)
{
- if((*src)->state == AL_PLAYING)
+ ALsource *source = (*src)->Source;
+ if(source->state == AL_PLAYING)
{
- (*src)->state = AL_STOPPED;
- (*src)->BuffersPlayed = (*src)->BuffersInQueue;
- (*src)->position = 0;
- (*src)->position_fraction = 0;
+ source->state = AL_STOPPED;
+ source->BuffersPlayed = source->BuffersInQueue;
+ source->position = 0;
+ source->position_fraction = 0;
}
src++;
}