aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h3
-rw-r--r--OpenAL32/alState.c74
2 files changed, 5 insertions, 72 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 8cbac90e..191c35b7 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -777,6 +777,9 @@ void ALCdevice_Lock(ALCdevice *device);
void ALCdevice_Unlock(ALCdevice *device);
ALint64 ALCdevice_GetLatency(ALCdevice *device);
+void ALCcontext_DeferUpdates(ALCcontext *context);
+void ALCcontext_ProcessUpdates(ALCcontext *context);
+
inline void LockContext(ALCcontext *context)
{ ALCdevice_Lock(context->Device); }
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index b4f17b9d..180a8c04 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -712,52 +712,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
context = GetContextRef();
if(!context) return;
- if(!context->DeferUpdates)
- {
- ALboolean UpdateSources;
- ALvoice *voice, *voice_end;
- ALeffectslot **slot, **slot_end;
- FPUCtl oldMode;
-
- SetMixerFPUMode(&oldMode);
-
- LockContext(context);
- context->DeferUpdates = AL_TRUE;
-
- /* Make sure all pending updates are performed */
- UpdateSources = ATOMIC_EXCHANGE(ALenum, &context->UpdateSources, AL_FALSE);
-
- voice = context->Voices;
- voice_end = voice + context->VoiceCount;
- while(voice != voice_end)
- {
- ALsource *source = voice->Source;
- if(!source) goto next;
-
- if(source->state != AL_PLAYING && source->state != AL_PAUSED)
- {
- voice->Source = NULL;
- continue;
- }
-
- if(ATOMIC_EXCHANGE(ALenum, &source->NeedsUpdate, AL_FALSE) || UpdateSources)
- voice->Update(voice, source, context);
- next:
- voice++;
- }
-
- slot = VECTOR_ITER_BEGIN(context->ActiveAuxSlots);
- slot_end = VECTOR_ITER_END(context->ActiveAuxSlots);
- while(slot != slot_end)
- {
- if(ATOMIC_EXCHANGE(ALenum, &(*slot)->NeedsUpdate, AL_FALSE))
- V((*slot)->EffectState,update)(context->Device, *slot);
- slot++;
- }
-
- UnlockContext(context);
- RestoreFPUMode(&oldMode);
- }
+ ALCcontext_DeferUpdates(context);
ALCcontext_DecRef(context);
}
@@ -769,32 +724,7 @@ AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
context = GetContextRef();
if(!context) return;
- LockContext(context);
- if(ExchangeInt(&context->DeferUpdates, AL_FALSE))
- {
- ALsizei pos;
-
- LockUIntMapRead(&context->SourceMap);
- for(pos = 0;pos < context->SourceMap.size;pos++)
- {
- ALsource *Source = context->SourceMap.array[pos].value;
- ALenum new_state;
-
- if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) &&
- Source->Offset >= 0.0)
- {
- ReadLock(&Source->queue_lock);
- ApplyOffset(Source);
- ReadUnlock(&Source->queue_lock);
- }
-
- new_state = ExchangeInt(&Source->new_state, AL_NONE);
- if(new_state)
- SetSourceState(Source, context, new_state);
- }
- UnlockUIntMapRead(&context->SourceMap);
- }
- UnlockContext(context);
+ ALCcontext_ProcessUpdates(context);
ALCcontext_DecRef(context);
}