diff options
author | Chris Robinson <[email protected]> | 2014-10-12 09:03:08 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-10-12 09:17:13 -0700 |
commit | 4320a1483b22eff1cc49b13570054064b321473b (patch) | |
tree | 8c41a696d5859db726837016297860817ec3e562 /OpenAL32 | |
parent | a77387b5490e8f40c682118c2a1c192cddc06939 (diff) |
Make alcSuspendContext and alcProcessContext batch updates
This behavior better matches Creative's hardware drivers and Rapture3D's OpenAL
driver. A compatibility environment variable is provided to restore the old
no-op behavior for any app that behaves badly from this change (set
__ALSOFT_SUSPEND_CONTEXT to "ignore").
If too many apps have a problem with this, the default behavior may need to be
changed to ignore, with the env var providing an option to defer/batch instead.
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 3 | ||||
-rw-r--r-- | OpenAL32/alState.c | 74 |
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); } |