aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--al/auxeffectslot.cpp22
-rw-r--r--al/auxeffectslot.h2
-rw-r--r--al/listener.cpp14
-rw-r--r--al/source.cpp4
-rw-r--r--al/source.h2
-rw-r--r--al/state.cpp14
-rw-r--r--alc/alc.cpp2
-rw-r--r--alc/context.cpp11
-rw-r--r--alc/context.h9
9 files changed, 39 insertions, 41 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index ad974483..50c5cda6 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -310,11 +310,12 @@ void FreeEffectSlot(ALCcontext *context, ALeffectslot *slot)
inline void UpdateProps(ALeffectslot *slot, ALCcontext *context)
{
- if(!context->mDeferUpdates.load(std::memory_order_acquire)
- && slot->mState == SlotState::Playing)
+ if(!context->mDeferUpdates && slot->mState == SlotState::Playing)
+ {
slot->updateProps(context);
- else
- slot->mPropsDirty.set(std::memory_order_release);
+ return;
+ }
+ slot->mPropsDirty = true;
}
} // namespace
@@ -466,7 +467,7 @@ START_API_FUNC
if(slot->mState == SlotState::Playing)
return;
- slot->mPropsDirty.test_and_clear(std::memory_order_acq_rel);
+ slot->mPropsDirty = false;
slot->updateProps(context.get());
AddActiveEffectSlots({&slot, 1}, context.get());
@@ -497,7 +498,7 @@ START_API_FUNC
if(slot->mState != SlotState::Playing)
{
- slot->mPropsDirty.test_and_clear(std::memory_order_acq_rel);
+ slot->mPropsDirty = false;
slot->updateProps(context.get());
}
slots[i] = slot;
@@ -598,7 +599,7 @@ START_API_FUNC
}
if UNLIKELY(slot->mState == SlotState::Initial)
{
- slot->mPropsDirty.test_and_clear(std::memory_order_acq_rel);
+ slot->mPropsDirty = false;
slot->updateProps(context.get());
AddActiveEffectSlots({&slot, 1}, context.get());
@@ -913,8 +914,6 @@ END_API_FUNC
ALeffectslot::ALeffectslot()
{
- mPropsDirty.test_and_clear(std::memory_order_relaxed);
-
EffectStateFactory *factory{getFactoryByType(EffectSlotType::None)};
assert(factory != nullptr);
@@ -1033,8 +1032,7 @@ void UpdateAllEffectSlotProps(ALCcontext *context)
ALeffectslot *slot{sublist.EffectSlots + idx};
usemask &= ~(1_u64 << idx);
- if(slot->mState != SlotState::Stopped
- && slot->mPropsDirty.test_and_clear(std::memory_order_acq_rel))
+ if(slot->mState != SlotState::Stopped && std::exchange(slot->mPropsDirty, false))
slot->updateProps(context);
}
}
@@ -1715,7 +1713,7 @@ void ALeffectslot::eax_set_effect_slot_effect(EaxEffect &effect)
if (mState == SlotState::Initial)
{
- mPropsDirty.test_and_clear(std::memory_order_acq_rel);
+ mPropsDirty = false;
updateProps(eax_al_context_);
auto effect_slot_ptr = this;
diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h
index 30f9caac..d845b2b4 100644
--- a/al/auxeffectslot.h
+++ b/al/auxeffectslot.h
@@ -48,7 +48,7 @@ struct ALeffectslot {
al::intrusive_ptr<EffectState> State;
} Effect;
- al::atomic_invflag mPropsDirty;
+ bool mPropsDirty{true};
SlotState mState{SlotState::Initial};
diff --git a/al/listener.cpp b/al/listener.cpp
index a260c93c..9484d9b1 100644
--- a/al/listener.cpp
+++ b/al/listener.cpp
@@ -40,16 +40,18 @@ namespace {
inline void UpdateProps(ALCcontext *context)
{
- if(!context->mDeferUpdates.load(std::memory_order_acquire))
+ if(!context->mDeferUpdates)
+ {
UpdateContextProps(context);
- else
- context->mPropsDirty.set(std::memory_order_release);
+ return;
+ }
+ context->mPropsDirty = true;
}
#ifdef ALSOFT_EAX
inline void CommitAndUpdateProps(ALCcontext *context)
{
- if(!context->mDeferUpdates.load(std::memory_order_acquire))
+ if(!context->mDeferUpdates)
{
if(context->has_eax())
{
@@ -62,9 +64,9 @@ inline void CommitAndUpdateProps(ALCcontext *context)
}
UpdateContextProps(context);
context->mHoldUpdates.store(false, std::memory_order_release);
+ return;
}
- else
- context->mPropsDirty.set(std::memory_order_release);
+ context->mPropsDirty = true;
}
#else
diff --git a/al/source.cpp b/al/source.cpp
index 08b8246b..e363b0da 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -1130,7 +1130,7 @@ void SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, const
void UpdateSourceProps(ALsource *source, ALCcontext *context)
{
- if(!context->mDeferUpdates.load(std::memory_order_acquire))
+ if(!context->mDeferUpdates)
{
if(Voice *voice{GetSourceVoice(source, context)})
{
@@ -1143,7 +1143,7 @@ void UpdateSourceProps(ALsource *source, ALCcontext *context)
#ifdef ALSOFT_EAX
void CommitAndUpdateSourceProps(ALsource *source, ALCcontext *context)
{
- if(!context->mDeferUpdates.load(std::memory_order_acquire))
+ if(!context->mDeferUpdates)
{
if(source->eax_is_initialized())
source->eax_commit();
diff --git a/al/source.h b/al/source.h
index 27e012af..24096a64 100644
--- a/al/source.h
+++ b/al/source.h
@@ -187,7 +187,7 @@ struct ALsource {
/** Source Buffer Queue head. */
al::deque<ALbufferQueueItem> mQueue;
- bool mPropsDirty{false};
+ bool mPropsDirty{true};
/* Index into the context's Voices array. Lazily updated, only checked and
* reset when looking up the voice.
diff --git a/al/state.cpp b/al/state.cpp
index 7d69e962..07fd1314 100644
--- a/al/state.cpp
+++ b/al/state.cpp
@@ -147,10 +147,10 @@ START_API_FUNC
END_API_FUNC
#define DO_UPDATEPROPS() do { \
- if(!context->mDeferUpdates.load(std::memory_order_acquire)) \
+ if(!context->mDeferUpdates) \
UpdateContextProps(context.get()); \
else \
- context->mPropsDirty.set(std::memory_order_release); \
+ context->mPropsDirty = true; \
} while(0)
@@ -263,7 +263,7 @@ START_API_FUNC
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(context->mDeferUpdates.load(std::memory_order_acquire))
+ if(context->mDeferUpdates)
value = AL_TRUE;
break;
@@ -316,7 +316,7 @@ START_API_FUNC
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(context->mDeferUpdates.load(std::memory_order_acquire))
+ if(context->mDeferUpdates)
value = static_cast<ALdouble>(AL_TRUE);
break;
@@ -367,7 +367,7 @@ START_API_FUNC
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(context->mDeferUpdates.load(std::memory_order_acquire))
+ if(context->mDeferUpdates)
value = static_cast<ALfloat>(AL_TRUE);
break;
@@ -418,7 +418,7 @@ START_API_FUNC
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(context->mDeferUpdates.load(std::memory_order_acquire))
+ if(context->mDeferUpdates)
value = AL_TRUE;
break;
@@ -504,7 +504,7 @@ START_API_FUNC
break;
case AL_DEFERRED_UPDATES_SOFT:
- if(context->mDeferUpdates.load(std::memory_order_acquire))
+ if(context->mDeferUpdates)
value = AL_TRUE;
break;
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 23bbb554..4c8d0a6c 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2155,7 +2155,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
context->mFreeVoiceProps.store(nullptr, std::memory_order_relaxed);
srclock.unlock();
- context->mPropsDirty.test_and_clear(std::memory_order_release);
+ context->mPropsDirty = false;
UpdateContextProps(context);
UpdateAllSourceProps(context);
}
diff --git a/alc/context.cpp b/alc/context.cpp
index 07dc76bf..c21bd1b9 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -114,7 +114,6 @@ void ALCcontext::setThreadContext(ALCcontext *context) noexcept
ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device)
: ContextBase{device.get()}, mALDevice{std::move(device)}
{
- mPropsDirty.test_and_clear(std::memory_order_relaxed);
}
ALCcontext::~ALCcontext()
@@ -258,7 +257,7 @@ void ALCcontext::applyAllUpdates()
/* busy-wait */
}
- if(mPropsDirty.test_and_clear(std::memory_order_acq_rel))
+ if(std::exchange(mPropsDirty, false))
UpdateContextProps(this);
UpdateAllEffectSlotProps(this);
UpdateAllSourceProps(this);
@@ -908,13 +907,13 @@ void ALCcontext::eax_set_primary_fx_slot_id()
void ALCcontext::eax_set_distance_factor()
{
mListener.mMetersPerUnit = eax_.context.flDistanceFactor;
- mPropsDirty.set(std::memory_order_release);
+ mPropsDirty = true;
}
void ALCcontext::eax_set_air_absorbtion_hf()
{
mAirAbsorptionGainHF = eax_.context.flAirAbsorptionHF;
- mPropsDirty.set(std::memory_order_release);
+ mPropsDirty = true;
}
void ALCcontext::eax_set_hf_reference()
@@ -1285,14 +1284,14 @@ void ALCcontext::eax_set(
if (!eax_call.is_deferred())
{
eax_apply_deferred();
- if(!mDeferUpdates.load(std::memory_order_acquire))
+ if(!mDeferUpdates)
{
mHoldUpdates.store(true, std::memory_order_release);
while((mUpdateCount.load(std::memory_order_acquire)&1) != 0) {
/* busy-wait */
}
- if(mPropsDirty.test_and_clear(std::memory_order_acq_rel))
+ if(std::exchange(mPropsDirty, false))
UpdateContextProps(this);
UpdateAllSourceProps(this);
diff --git a/alc/context.h b/alc/context.h
index bd966704..64c484a8 100644
--- a/alc/context.h
+++ b/alc/context.h
@@ -102,8 +102,8 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
al::vector<WetBufferPtr> mWetBuffers;
- al::atomic_invflag mPropsDirty;
- std::atomic<bool> mDeferUpdates{false};
+ bool mPropsDirty{true};
+ bool mDeferUpdates{false};
std::mutex mPropLock;
@@ -155,8 +155,7 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
* This does *NOT* stop mixing, but rather prevents certain property
* changes from taking effect. mPropLock must be held when called.
*/
- bool deferUpdates() noexcept
- { return mDeferUpdates.exchange(true, std::memory_order_acq_rel); }
+ void deferUpdates() noexcept { mDeferUpdates = true; }
/**
* Resumes update processing after being deferred. mPropLock must be held
@@ -164,7 +163,7 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
*/
void processUpdates()
{
- if(mDeferUpdates.exchange(false, std::memory_order_acq_rel))
+ if(std::exchange(mDeferUpdates, false))
applyAllUpdates();
}