From 56d3598020f553681ec88b830c21218556a80a84 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 8 Aug 2016 22:31:08 -0700 Subject: Avoid checking DeferUpdates for each source state change --- OpenAL32/alSource.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 0e98f2f5..fb2ada10 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -2316,13 +2316,21 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) context->MaxVoices = newcount; } - for(i = 0;i < n;i++) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) { - source = LookupSource(context, sources[i]); - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) + for(i = 0;i < n;i++) + { + source = LookupSource(context, sources[i]); source->new_state = AL_PLAYING; - else + } + } + else + { + for(i = 0;i < n;i++) + { + source = LookupSource(context, sources[i]); SetSourceState(source, context, AL_PLAYING); + } } UnlockContext(context); @@ -2354,13 +2362,21 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) } LockContext(context); - for(i = 0;i < n;i++) + if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) { - source = LookupSource(context, sources[i]); - if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) + for(i = 0;i < n;i++) + { + source = LookupSource(context, sources[i]); source->new_state = AL_PAUSED; - else + } + } + else + { + for(i = 0;i < n;i++) + { + source = LookupSource(context, sources[i]); SetSourceState(source, context, AL_PAUSED); + } } UnlockContext(context); -- cgit v1.2.3