aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-15 17:14:58 -0700
committerChris Robinson <[email protected]>2016-05-15 22:16:27 -0700
commit945fd022d6c9d612a5fae944d8cbef68927d8a92 (patch)
tree88a1fdfd2890c0f9f0ee4d3a541571177609f2bc /Alc
parent63e98481eef0eb02dac14b889be80836a300eecc (diff)
Avoid separate updates to sources that should apply together
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c2
-rw-r--r--Alc/ALu.c29
2 files changed, 19 insertions, 12 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 0019de9e..86b8e59e 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2266,6 +2266,8 @@ static ALvoid InitContext(ALCcontext *Context)
ATOMIC_INIT(&listener->FreeList, NULL);
//Validate Context
+ InitRef(&Context->UpdateCount, 0);
+ ATOMIC_INIT(&Context->HoldUpdates, AL_FALSE);
RWLockInit(&Context->PropLock);
ATOMIC_INIT(&Context->LastError, AL_NO_ERROR);
InitUIntMap(&Context->SourceMap, Context->Device->MaxNoOfSources);
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 329d01eb..34c36d5b 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1339,26 +1339,31 @@ ALvoid CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *props, c
}
-void UpdateContextSources(ALCcontext *ctx)
+static void UpdateContextSources(ALCcontext *ctx)
{
ALvoice *voice, *voice_end;
ALsource *source;
- CalcListenerParams(ctx);
+ IncrementRef(&ctx->UpdateCount);
+ if(!ATOMIC_LOAD(&ctx->HoldUpdates))
+ {
+ CalcListenerParams(ctx);
#define UPDATE_SLOT(iter) CalcEffectSlotParams(*iter, ctx->Device)
- VECTOR_FOR_EACH(ALeffectslot*, ctx->ActiveAuxSlots, UPDATE_SLOT);
+ VECTOR_FOR_EACH(ALeffectslot*, ctx->ActiveAuxSlots, UPDATE_SLOT);
#undef UPDATE_SLOT
- voice = ctx->Voices;
- voice_end = voice + ctx->VoiceCount;
- for(;voice != voice_end;++voice)
- {
- if(!(source=voice->Source)) continue;
- if(source->state != AL_PLAYING && source->state != AL_PAUSED)
- voice->Source = NULL;
- else
- CalcSourceParams(voice, ctx);
+ voice = ctx->Voices;
+ voice_end = voice + ctx->VoiceCount;
+ for(;voice != voice_end;++voice)
+ {
+ if(!(source=voice->Source)) continue;
+ if(source->state != AL_PLAYING && source->state != AL_PAUSED)
+ voice->Source = NULL;
+ else
+ CalcSourceParams(voice, ctx);
+ }
}
+ IncrementRef(&ctx->UpdateCount);
}