diff options
author | Chris Robinson <[email protected]> | 2010-06-06 00:17:50 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-06-06 00:17:50 -0700 |
commit | 7f6df7695c9c8cd957339f85e57233f5d3308e49 (patch) | |
tree | 19d67ce16718276dceb3509c30d192c6dc518826 /Alc/ALc.c | |
parent | ed585710790c35a2624586d9f387c261cf1bff48 (diff) |
Use an array of active sources when mixing
Prevents iterating over all allocated sources during mixing updates
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -892,6 +892,7 @@ static ALvoid InitContext(ALCcontext *pContext) //Validate pContext pContext->LastError = AL_NO_ERROR; pContext->Suspended = AL_FALSE; + pContext->ActiveSourceCount = 0; InitUIntMap(&pContext->SourceMap); //Set globals @@ -1613,8 +1614,15 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin device->Contexts = temp; ALContext = calloc(1, sizeof(ALCcontext)); - if(!ALContext) + if(ALContext) { + ALContext->MaxActiveSources = 256; + ALContext->ActiveSources = malloc(sizeof(*ALContext->ActiveSources) * + ALContext->MaxActiveSources); + } + if(!ALContext || !ALContext->ActiveSources) + { + free(ALContext); alcSetError(device, ALC_OUT_OF_MEMORY); ProcessContext(NULL); return NULL; @@ -1693,6 +1701,11 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context) } ResetUIntMap(&context->EffectSlotMap); + free(context->ActiveSources); + context->ActiveSources = NULL; + context->MaxActiveSources = 0; + context->ActiveSourceCount = 0; + list = &g_pContextList; while(*list != context) list = &(*list)->next; |