aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
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 /OpenAL32
parent1e31ac469e129ccd5cde5fb890b31fa8b6815a9b (diff)
Use atomic_flags and atomic<bools>s where appropriate
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h2
-rw-r--r--OpenAL32/Include/alListener.h2
-rw-r--r--OpenAL32/Include/alSource.h2
-rw-r--r--OpenAL32/alAuxEffectSlot.cpp4
-rw-r--r--OpenAL32/alListener.cpp8
-rw-r--r--OpenAL32/alSource.cpp12
-rw-r--r--OpenAL32/alState.cpp14
7 files changed, 21 insertions, 23 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 6e315e8f..dd44b436 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -69,7 +69,7 @@ struct ALeffectslot {
EffectState *State{nullptr};
} Effect;
- ATOMIC(ALenum) PropsClean{AL_TRUE};
+ std::atomic_flag PropsClean{true};
RefCount ref{0u};
diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h
index 1e0a8265..6b1dcda9 100644
--- a/OpenAL32/Include/alListener.h
+++ b/OpenAL32/Include/alListener.h
@@ -28,7 +28,7 @@ struct ALlistener {
ALfloat Up[3]{0.0f, 1.0f, 0.0f};
ALfloat Gain{1.0f};
- ATOMIC(ALenum) PropsClean{AL_TRUE};
+ std::atomic_flag PropsClean{true};
/* Pointer to the most recent property values that are awaiting an update.
*/
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 3d7d733e..9ad5577d 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -97,7 +97,7 @@ typedef struct ALsource {
/** Source Buffer Queue head. */
ALbufferlistitem *queue;
- ATOMIC(ALenum) PropsClean;
+ std::atomic_flag PropsClean{true};
/* Index into the context's Voices array. Lazily updated, only checked and
* reset when looking up the voice.
diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp
index ea1765bb..df2c2a43 100644
--- a/OpenAL32/alAuxEffectSlot.cpp
+++ b/OpenAL32/alAuxEffectSlot.cpp
@@ -175,7 +175,7 @@ inline EffectStateFactory *getFactoryByType(ALenum type)
if(!context->DeferUpdates.load(std::memory_order_acquire)) \
UpdateEffectSlotProps(slot, context.get()); \
else \
- slot->PropsClean.store(AL_FALSE, std::memory_order_release); \
+ slot->PropsClean.clear(std::memory_order_release); \
} while(0)
} // namespace
@@ -652,7 +652,7 @@ void UpdateAllEffectSlotProps(ALCcontext *context)
for(ALsizei i{0};i < auxslots->count;i++)
{
ALeffectslot *slot = auxslots->slot[i];
- if(!slot->PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel))
+ if(!slot->PropsClean.test_and_set(std::memory_order_acq_rel))
UpdateEffectSlotProps(slot, context);
}
}
diff --git a/OpenAL32/alListener.cpp b/OpenAL32/alListener.cpp
index d60f5254..bd004368 100644
--- a/OpenAL32/alListener.cpp
+++ b/OpenAL32/alListener.cpp
@@ -30,10 +30,10 @@
#include "alSource.h"
#define DO_UPDATEPROPS() do { \
- if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \
+ if(!context->DeferUpdates.load(std::memory_order_acquire)) \
UpdateListenerProps(context); \
else \
- ATOMIC_STORE(&listener->PropsClean, AL_FALSE, almemory_order_release);\
+ listener->PropsClean.clear(std::memory_order_release); \
} while(0)
@@ -60,10 +60,10 @@ AL_API ALvoid AL_APIENTRY alListenerf(ALenum param, ALfloat value)
if(!(value >= AL_MIN_METERS_PER_UNIT && value <= AL_MAX_METERS_PER_UNIT))
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Listener meters per unit out of range");
context->MetersPerUnit = value;
- if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
+ if(!context->DeferUpdates.load(std::memory_order_acquire))
UpdateContextProps(context);
else
- ATOMIC_STORE(&context->PropsClean, AL_FALSE, almemory_order_release);
+ context->PropsClean.clear(std::memory_order_release);
break;
default:
diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp
index 2c452918..c487d877 100644
--- a/OpenAL32/alSource.cpp
+++ b/OpenAL32/alSource.cpp
@@ -222,7 +222,7 @@ static inline ALenum GetSourceState(ALsource *source, ALvoice *voice)
*/
static inline bool SourceShouldUpdate(ALsource *source, ALCcontext *context)
{
- return !ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire) &&
+ return !context->DeferUpdates.load(std::memory_order_acquire) &&
IsPlayingOrPaused(source);
}
@@ -520,7 +520,7 @@ static ALint Int64ValsByProp(ALenum prop)
(voice=GetSourceVoice(Source, Context)) != NULL) \
UpdateSourceProps(Source, voice, device->NumAuxSends, Context); \
else \
- ATOMIC_STORE(&Source->PropsClean, AL_FALSE, almemory_order_release); \
+ Source->PropsClean.clear(std::memory_order_release); \
} while(0)
static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const ALfloat *values)
@@ -1038,7 +1038,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
if((voice=GetSourceVoice(Source, Context)) != NULL)
UpdateSourceProps(Source, voice, device->NumAuxSends, Context);
else
- ATOMIC_STORE(&Source->PropsClean, AL_FALSE, almemory_order_release);
+ Source->PropsClean.clear(std::memory_order_release);
}
else
{
@@ -2489,7 +2489,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
voice = context->Voices[vidx];
voice->Playing.store(false, std::memory_order_release);
- source->PropsClean.exchange(AL_TRUE, std::memory_order_acquire);
+ source->PropsClean.test_and_set(std::memory_order_acquire);
UpdateSourceProps(source, voice, device->NumAuxSends, context);
/* A source that's not playing or paused has any offset applied when it
@@ -3113,8 +3113,6 @@ static void InitSourceParams(ALsource *Source, ALsizei num_sends)
Source->queue = NULL;
- ATOMIC_INIT(&Source->PropsClean, AL_TRUE);
-
Source->VoiceIdx = -1;
}
@@ -3248,7 +3246,7 @@ void UpdateAllSourceProps(ALCcontext *context)
{
ALvoice *voice = context->Voices[pos];
ALsource *source = ATOMIC_LOAD(&voice->Source, almemory_order_acquire);
- if(source && !source->PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel))
+ if(source && !source->PropsClean.test_and_set(std::memory_order_acq_rel))
UpdateSourceProps(source, voice, num_sends, context);
}
}
diff --git a/OpenAL32/alState.cpp b/OpenAL32/alState.cpp
index e3e8856f..2901baa2 100644
--- a/OpenAL32/alState.cpp
+++ b/OpenAL32/alState.cpp
@@ -67,10 +67,10 @@ extern "C" AL_API const ALchar* AL_APIENTRY alsoft_get_version(void)
}
#define DO_UPDATEPROPS() do { \
- if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \
+ if(!context->DeferUpdates.load(std::memory_order_acquire)) \
UpdateContextProps(context.get()); \
else \
- ATOMIC_STORE(&context->PropsClean, AL_FALSE, almemory_order_release); \
+ context->PropsClean.clear(std::memory_order_release); \
} while(0)
@@ -160,7 +160,7 @@ AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
+ if(context->DeferUpdates.load(std::memory_order_acquire))
value = AL_TRUE;
break;
@@ -211,7 +211,7 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
+ if(context->DeferUpdates.load(std::memory_order_acquire))
value = (ALdouble)AL_TRUE;
break;
@@ -260,7 +260,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
+ if(context->DeferUpdates.load(std::memory_order_acquire))
value = (ALfloat)AL_TRUE;
break;
@@ -309,7 +309,7 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
+ if(context->DeferUpdates.load(std::memory_order_acquire))
value = (ALint)AL_TRUE;
break;
@@ -358,7 +358,7 @@ extern "C" AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname)
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire))
+ if(context->DeferUpdates.load(std::memory_order_acquire))
value = (ALint64SOFT)AL_TRUE;
break;