diff options
-rw-r--r-- | Alc/ALu.c | 14 | ||||
-rw-r--r-- | OpenAL32/alState.c | 44 |
2 files changed, 52 insertions, 6 deletions
@@ -979,10 +979,14 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) ctx_end = ctx + device->NumContexts; while(ctx != ctx_end) { - ALboolean UpdateSources; + ALboolean DeferUpdates = (*ctx)->DeferUpdates; + ALboolean UpdateSources = AL_FALSE; - UpdateSources = (*ctx)->UpdateSources; - (*ctx)->UpdateSources = AL_FALSE; + if(!DeferUpdates) + { + UpdateSources = (*ctx)->UpdateSources; + (*ctx)->UpdateSources = AL_FALSE; + } src = (*ctx)->ActiveSources; src_end = src + (*ctx)->ActiveSourceCount; @@ -995,7 +999,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) continue; } - if((*src)->NeedsUpdate || UpdateSources) + if(!DeferUpdates && ((*src)->NeedsUpdate || UpdateSources)) { (*src)->NeedsUpdate = AL_FALSE; ALsource_Update(*src, *ctx); @@ -1021,7 +1025,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) ALEffectSlot->PendingClicks[i] = 0.0f; } - if(ALEffectSlot->NeedsUpdate) + if(!DeferUpdates && ALEffectSlot->NeedsUpdate) { ALEffectSlot->NeedsUpdate = AL_FALSE; ALEffect_Update(ALEffectSlot->EffectState, *ctx, ALEffectSlot); 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); } |