aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-03-27 23:16:23 -0700
committerChris Robinson <[email protected]>2017-03-27 23:16:23 -0700
commit70aefa75e2253ef7a93cdd6412e8523663d3c6e9 (patch)
tree82e740fbebe8d1ebe71082d3b40f807247484618 /Alc
parentb49a79a15fa16e93e2e2ff1fc76dbae0425fd503 (diff)
Use an array of pointers for effects instead of a linked list
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c12
-rw-r--r--Alc/ALu.c34
2 files changed, 26 insertions, 20 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 8d241802..84007020 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2449,6 +2449,7 @@ static ALCboolean VerifyDevice(ALCdevice **device)
static ALvoid InitContext(ALCcontext *Context)
{
ALlistener *listener = Context->Listener;
+ struct ALeffectslotArray *auxslots;
//Initialise listener
listener->Gain = 1.0f;
@@ -2490,6 +2491,10 @@ static ALvoid InitContext(ALCcontext *Context)
InitUIntMap(&Context->SourceMap, Context->Device->SourcesMax);
InitUIntMap(&Context->EffectSlotMap, Context->Device->AuxiliaryEffectSlotMax);
+ auxslots = al_calloc(DEF_ALIGN, offsetof(struct ALeffectslotArray, slot[0]));
+ auxslots->count = 0;
+ ATOMIC_INIT(&Context->ActiveAuxSlots, auxslots);
+
//Set globals
Context->DistanceModel = DefaultDistanceModel;
Context->SourceDistanceModel = AL_FALSE;
@@ -2510,11 +2515,16 @@ static ALvoid InitContext(ALCcontext *Context)
static void FreeContext(ALCcontext *context)
{
ALlistener *listener = context->Listener;
+ struct ALeffectslotArray *auxslots;
struct ALlistenerProps *lprops;
size_t count;
TRACE("%p\n", context);
+ auxslots = ATOMIC_EXCHANGE(struct ALeffectslotArray*, &context->ActiveAuxSlots,
+ NULL, almemory_order_relaxed);
+ al_free(auxslots);
+
if(context->SourceMap.size > 0)
{
WARN("(%p) Deleting %d Source%s\n", context, context->SourceMap.size,
@@ -3511,7 +3521,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ALContext->Listener = (ALlistener*)ALContext->_listener_mem;
ALContext->Device = device;
- ATOMIC_INIT(&ALContext->ActiveAuxSlotList, NULL);
+ ATOMIC_INIT(&ALContext->ActiveAuxSlots, NULL);
ALContext->Voices = NULL;
ALContext->MaxVoices = 0;
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 7936c706..f0e4d735 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1281,20 +1281,18 @@ static void CalcSourceParams(ALvoice *voice, ALsource *source, ALCcontext *conte
}
-static void UpdateContextSources(ALCcontext *ctx, ALeffectslot *slot)
+static void UpdateContextSources(ALCcontext *ctx, const struct ALeffectslotArray *slots)
{
ALvoice **voice, **voice_end;
ALsource *source;
+ ALsizei i;
IncrementRef(&ctx->UpdateCount);
if(!ATOMIC_LOAD(&ctx->HoldUpdates, almemory_order_acquire))
{
ALboolean force = CalcListenerParams(ctx);
- while(slot)
- {
- force |= CalcEffectSlotParams(slot, ctx->Device);
- slot = ATOMIC_LOAD(&slot->next, almemory_order_relaxed);
- }
+ for(i = 0;i < slots->count;i++)
+ force |= CalcEffectSlotParams(slots->slot[i], ctx->Device);
voice = ctx->Voices;
voice_end = voice + ctx->VoiceCount;
@@ -1417,24 +1415,23 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
if((slot=device->DefaultSlot) != NULL)
{
CalcEffectSlotParams(device->DefaultSlot, device);
- for(i = 0;i < slot->NumChannels;i++)
- memset(slot->WetBuffer[i], 0, SamplesToDo*sizeof(ALfloat));
+ for(c = 0;c < slot->NumChannels;c++)
+ memset(slot->WetBuffer[c], 0, SamplesToDo*sizeof(ALfloat));
}
ctx = ATOMIC_LOAD(&device->ContextList, almemory_order_acquire);
while(ctx)
{
- ALeffectslot *slotroot;
+ const struct ALeffectslotArray *auxslots;
- slotroot = ATOMIC_LOAD(&ctx->ActiveAuxSlotList, almemory_order_acquire);
- UpdateContextSources(ctx, slotroot);
+ auxslots = ATOMIC_LOAD(&ctx->ActiveAuxSlots, almemory_order_acquire);
+ UpdateContextSources(ctx, auxslots);
- slot = slotroot;
- while(slot)
+ for(i = 0;i < auxslots->count;i++)
{
- for(i = 0;i < slot->NumChannels;i++)
- memset(slot->WetBuffer[i], 0, SamplesToDo*sizeof(ALfloat));
- slot = ATOMIC_LOAD(&slot->next, almemory_order_relaxed);
+ ALeffectslot *slot = auxslots->slot[i];
+ for(c = 0;c < slot->NumChannels;c++)
+ memset(slot->WetBuffer[c], 0, SamplesToDo*sizeof(ALfloat));
}
/* source processing */
@@ -1455,13 +1452,12 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
}
/* effect slot processing */
- slot = slotroot;
- while(slot)
+ for(i = 0;i < auxslots->count;i++)
{
+ ALeffectslot *slot = auxslots->slot[i];
ALeffectState *state = slot->Params.EffectState;
V(state,process)(SamplesToDo, SAFE_CONST(ALfloatBUFFERSIZE*,slot->WetBuffer),
state->OutBuffer, state->OutChannels);
- slot = ATOMIC_LOAD(&slot->next, almemory_order_relaxed);
}
ctx = ctx->next;