aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-22 17:13:03 -0700
committerChris Robinson <[email protected]>2011-08-22 17:13:03 -0700
commit65d42083e1d88e3ef024325f08e6266a87dc03d7 (patch)
tree76358068ad3334a73057144ff592e4ac2356314f /OpenAL32
parent6992a67dd9a496e1440517b1d49a03f3d5a46f45 (diff)
Prevent source and effect slot updates from occuring while updates are deferred
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alState.c44
1 files changed, 43 insertions, 1 deletions
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);
}