From 58078e2c1eb2a3778462c1d0632b0a2c85fe82ec Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 29 Aug 2011 00:50:55 -0700 Subject: Use atomic exchanges when checking for updates to objects' internal parameters --- Alc/ALu.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index d7eba154..b11a1c3a 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -978,14 +978,11 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) ctx = device->ContextList; while(ctx) { - ALboolean DeferUpdates = ctx->DeferUpdates; - ALboolean UpdateSources = AL_FALSE; + ALenum DeferUpdates = ctx->DeferUpdates; + ALenum UpdateSources = AL_FALSE; if(!DeferUpdates) - { - UpdateSources = ctx->UpdateSources; - ctx->UpdateSources = AL_FALSE; - } + UpdateSources = Exchange_ALenum(&ctx->UpdateSources, AL_FALSE); src = ctx->ActiveSources; src_end = src + ctx->ActiveSourceCount; @@ -998,11 +995,9 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) continue; } - if(!DeferUpdates && ((*src)->NeedsUpdate || UpdateSources)) - { - (*src)->NeedsUpdate = AL_FALSE; + if(!DeferUpdates && (Exchange_ALenum(&(*src)->NeedsUpdate, AL_FALSE) || + UpdateSources)) ALsource_Update(*src, ctx); - } MixSource(*src, device, SamplesToDo); src++; @@ -1024,11 +1019,8 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) ALEffectSlot->PendingClicks[i] = 0.0f; } - if(!DeferUpdates && ALEffectSlot->NeedsUpdate) - { - ALEffectSlot->NeedsUpdate = AL_FALSE; + if(!DeferUpdates && Exchange_ALenum(&ALEffectSlot->NeedsUpdate, AL_FALSE)) ALEffect_Update(ALEffectSlot->EffectState, ctx, ALEffectSlot); - } ALEffect_Process(ALEffectSlot->EffectState, ALEffectSlot, SamplesToDo, ALEffectSlot->WetBuffer, -- cgit v1.2.3