aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-20 10:45:01 -0800
committerChris Robinson <[email protected]>2018-11-20 10:45:01 -0800
commit191ea90de3994f9e98377ea9318c4c7b6885179c (patch)
tree53d42071b9ff0693b706c956a56f760361a11d41 /Alc
parent1e31ac469e129ccd5cde5fb890b31fa8b6815a9b (diff)
Use atomic_flags and atomic<bools>s where appropriate
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alc.cpp16
-rw-r--r--Alc/alcontext.h4
2 files changed, 9 insertions, 11 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 10a1511e..00148246 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -1604,7 +1604,7 @@ void SetDefaultChannelOrder(ALCdevice *device)
*/
void ALCcontext_DeferUpdates(ALCcontext *context)
{
- ATOMIC_STORE_SEQ(&context->DeferUpdates, AL_TRUE);
+ context->DeferUpdates.store(true);
}
/* ALCcontext_ProcessUpdates
@@ -1614,7 +1614,7 @@ void ALCcontext_DeferUpdates(ALCcontext *context)
void ALCcontext_ProcessUpdates(ALCcontext *context)
{
almtx_lock(&context->PropLock);
- if(context->DeferUpdates.exchange(AL_FALSE))
+ if(context->DeferUpdates.exchange(false))
{
/* Tell the mixer to stop applying updates, then wait for any active
* updating to finish, before providing updates.
@@ -1623,9 +1623,9 @@ void ALCcontext_ProcessUpdates(ALCcontext *context)
while((ATOMIC_LOAD(&context->UpdateCount, almemory_order_acquire)&1) != 0)
althrd_yield();
- if(!context->PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel))
+ if(!context->PropsClean.test_and_set(std::memory_order_acq_rel))
UpdateContextProps(context);
- if(!context->Listener.PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel))
+ if(!context->Listener.PropsClean.test_and_set(std::memory_order_acq_rel))
UpdateListenerProps(context);
UpdateAllEffectSlotProps(context);
UpdateAllSourceProps(context);
@@ -2319,7 +2319,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
}
}
- ATOMIC_STORE(&source->PropsClean, AL_FALSE, almemory_order_release);
+ source->PropsClean.clear(std::memory_order_release);
}
}
@@ -2356,9 +2356,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
}
almtx_unlock(&context->SourceLock);
- ATOMIC_STORE(&context->PropsClean, AL_TRUE, almemory_order_release);
+ context->PropsClean.test_and_set(std::memory_order_release);
UpdateContextProps(context);
- ATOMIC_STORE(&context->Listener.PropsClean, AL_TRUE, almemory_order_release);
+ context->Listener.PropsClean.test_and_set(std::memory_order_release);
UpdateListenerProps(context);
UpdateAllSourceProps(context);
almtx_unlock(&context->PropLock);
@@ -2538,8 +2538,6 @@ static ALvoid InitContext(ALCcontext *Context)
Context->DopplerVelocity = 1.0f;
Context->SpeedOfSound = SPEEDOFSOUNDMETRESPERSEC;
Context->MetersPerUnit = AL_DEFAULT_METERS_PER_UNIT;
- ATOMIC_INIT(&Context->PropsClean, AL_TRUE);
- ATOMIC_INIT(&Context->DeferUpdates, AL_FALSE);
alsem_init(&Context->EventSem, 0);
almtx_init(&Context->EventCbLock, almtx_plain);
diff --git a/Alc/alcontext.h b/Alc/alcontext.h
index 424f1447..ce715bc2 100644
--- a/Alc/alcontext.h
+++ b/Alc/alcontext.h
@@ -69,8 +69,8 @@ struct ALCcontext_struct {
ALfloat SpeedOfSound{};
ALfloat MetersPerUnit{1.0f};
- ATOMIC(ALenum) PropsClean{AL_TRUE};
- ATOMIC(ALenum) DeferUpdates{AL_FALSE};
+ std::atomic_flag PropsClean{true};
+ std::atomic<bool> DeferUpdates{false};
almtx_t PropLock;