diff options
author | Chris Robinson <[email protected]> | 2021-04-15 15:07:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-04-15 15:17:04 -0700 |
commit | 29cf7ebb752e00e116391a1df7a3ed0f49fdd193 (patch) | |
tree | 76b90d55cbcbae2bb3c04fc95aaef83161263ecc /al/source.cpp | |
parent | 92148a3a044389863601b8b907bcfc69ff77b869 (diff) |
Make an inverted atomic flag type and use it
The inverted atomic flag replaces test_and_set+clear with test_and_clear+set,
essentially inverting the flag status. This makes more logical sense for
flagging dirty state, which is less confusing than flagging clean state. The
one caveat is ATOMIC_FLAG_INIT (or default construction in C++20) initializes
the state to true rather than false.
Diffstat (limited to 'al/source.cpp')
-rw-r--r-- | al/source.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/al/source.cpp b/al/source.cpp index 72337d74..218682d8 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -466,7 +466,7 @@ void InitVoice(Voice *voice, ALsource *source, ALbufferQueueItem *BufferList, AL voice->prepare(device); - source->PropsClean.test_and_set(std::memory_order_acq_rel); + source->mPropsDirty.test_and_clear(std::memory_order_acq_rel); UpdateSourceProps(source, voice, context); voice->mSourceID.store(source->id, std::memory_order_release); @@ -1057,7 +1057,7 @@ bool UpdateSourceProps(ALsource *source, ALCcontext *context) if(SourceShouldUpdate(source, context) && (voice=GetSourceVoice(source, context)) != nullptr) UpdateSourceProps(source, voice, context); else - source->PropsClean.clear(std::memory_order_release); + source->mPropsDirty.set(std::memory_order_release); return true; } @@ -1539,7 +1539,7 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a */ Voice *voice{GetSourceVoice(Source, Context)}; if(voice) UpdateSourceProps(Source, voice, Context); - else Source->PropsClean.clear(std::memory_order_release); + else Source->mPropsDirty.set(std::memory_order_release); } else { @@ -3386,7 +3386,7 @@ ALsource::ALsource() send.LFReference = HIGHPASSFREQREF; } - PropsClean.test_and_set(std::memory_order_relaxed); + mPropsDirty.test_and_clear(std::memory_order_relaxed); } ALsource::~ALsource() @@ -3413,7 +3413,7 @@ void UpdateAllSourceProps(ALCcontext *context) ALsource *source = sid ? LookupSource(context, sid) : nullptr; if(source && source->VoiceIdx == vidx) { - if(!source->PropsClean.test_and_set(std::memory_order_acq_rel)) + if(!source->mPropsDirty.test_and_clear(std::memory_order_acq_rel)) UpdateSourceProps(source, voice, context); } ++vidx; |