From 65d42083e1d88e3ef024325f08e6266a87dc03d7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 22 Aug 2011 17:13:03 -0700 Subject: Prevent source and effect slot updates from occuring while updates are deferred --- OpenAL32/alState.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'OpenAL32/alState.c') diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 38952100..8e4c4671 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -26,6 +26,7 @@ #include "AL/alext.h" #include "alError.h" #include "alSource.h" +#include "alAuxEffectSlot.h" #include "alState.h" static const ALchar alVendor[] = "OpenAL Community"; @@ -579,7 +580,48 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) Context = GetLockedContext(); if(!Context) return; - Context->DeferUpdates = AL_TRUE; + if(!Context->DeferUpdates) + { + ALboolean UpdateSources; + ALsource **src, **src_end; + ALeffectslot *ALEffectSlot; + ALsizei e; + + Context->DeferUpdates = AL_TRUE; + + /* Make sure all pending updates are performed */ + UpdateSources = Context->UpdateSources; + Context->UpdateSources = AL_FALSE; + + src = Context->ActiveSources; + src_end = src + Context->ActiveSourceCount; + while(src != src_end) + { + if((*src)->state != AL_PLAYING) + { + Context->ActiveSourceCount--; + *src = *(--src_end); + continue; + } + + if((*src)->NeedsUpdate || UpdateSources) + { + (*src)->NeedsUpdate = AL_FALSE; + ALsource_Update(*src, Context); + } + src++; + } + + for(e = 0;e < Context->EffectSlotMap.size;e++) + { + ALEffectSlot = Context->EffectSlotMap.array[e].value; + if(ALEffectSlot->NeedsUpdate) + { + ALEffectSlot->NeedsUpdate = AL_FALSE; + ALEffect_Update(ALEffectSlot->EffectState, Context, ALEffectSlot); + } + } + } UnlockContext(Context); } -- cgit v1.2.3