diff options
author | Chris Robinson <[email protected]> | 2017-09-27 09:36:34 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-09-27 09:36:34 -0700 |
commit | fd70b0bca6dcc97edf16d4567c84933576828230 (patch) | |
tree | 49871e67457b3f363a7d44d63a3b9d84c8f58d62 /OpenAL32/alState.c | |
parent | 101d284a1801532e12b7867aed3499896d7a9a6f (diff) |
Don't update context and listener props unnecessarily
Diffstat (limited to 'OpenAL32/alState.c')
-rw-r--r-- | OpenAL32/alState.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 86534efb..14646043 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -54,6 +54,14 @@ static const ALchar alSinc4Resampler[] = "3rd order Sinc"; static const ALchar alBSinc12Resampler[] = "11th order Sinc"; static const ALchar alBSinc24Resampler[] = "23rd order Sinc"; +#define DO_UPDATEPROPS() do { \ + if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \ + UpdateContextProps(context); \ + else \ + ATOMIC_FLAG_CLEAR(&context->PropsClean, almemory_order_release); \ +} while(0) + + AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) { ALCcontext *context; @@ -66,13 +74,12 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) { case AL_SOURCE_DISTANCE_MODEL: context->SourceDistanceModel = AL_TRUE; + DO_UPDATEPROPS(); break; default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateContextProps(context); done: WriteUnlock(&context->PropLock); @@ -91,13 +98,12 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability) { case AL_SOURCE_DISTANCE_MODEL: context->SourceDistanceModel = AL_FALSE; + DO_UPDATEPROPS(); break; default: SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); } - if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateContextProps(context); done: WriteUnlock(&context->PropLock); @@ -647,8 +653,7 @@ AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value) WriteLock(&context->PropLock); context->DopplerFactor = value; - if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateContextProps(context); + DO_UPDATEPROPS(); WriteUnlock(&context->PropLock); done: @@ -667,8 +672,7 @@ AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value) WriteLock(&context->PropLock); context->DopplerVelocity = value; - if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateContextProps(context); + DO_UPDATEPROPS(); WriteUnlock(&context->PropLock); done: @@ -687,8 +691,7 @@ AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat value) WriteLock(&context->PropLock); context->SpeedOfSound = value; - if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateContextProps(context); + DO_UPDATEPROPS(); WriteUnlock(&context->PropLock); done: @@ -711,10 +714,7 @@ AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value) WriteLock(&context->PropLock); context->DistanceModel = value; if(!context->SourceDistanceModel) - { - if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) - UpdateContextProps(context); - } + DO_UPDATEPROPS(); WriteUnlock(&context->PropLock); done: |