aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-03-16 02:46:19 -0700
committerChris Robinson <[email protected]>2023-03-16 02:46:19 -0700
commitef5373611fb0411be0e29c463f0e525481011eb0 (patch)
tree5d5e49a0bebe207853803a2406ac815326e0c4b1
parenta4b1986556f5c21f77b58b619312fcb7d5435e97 (diff)
Commit deferred EAX properties in alcProcessContext
-rw-r--r--al/listener.cpp21
-rw-r--r--al/source.cpp15
-rw-r--r--al/source.h1
-rw-r--r--alc/context.cpp17
-rw-r--r--alc/context.h8
5 files changed, 17 insertions, 45 deletions
diff --git a/al/listener.cpp b/al/listener.cpp
index 2a9b77f3..2a9f2cb3 100644
--- a/al/listener.cpp
+++ b/al/listener.cpp
@@ -48,33 +48,24 @@ inline void UpdateProps(ALCcontext *context)
context->mPropsDirty = true;
}
-#ifdef ALSOFT_EAX
inline void CommitAndUpdateProps(ALCcontext *context)
{
if(!context->mDeferUpdates)
{
- if(context->has_eax())
+#ifdef ALSOFT_EAX
+ if(context->eax_needs_commit())
{
- context->mHoldUpdates.store(true, std::memory_order_release);
- while((context->mUpdateCount.load(std::memory_order_acquire)&1) != 0) {
- /* busy-wait */
- }
-
- context->eax_commit_and_update_sources();
+ context->mPropsDirty = true;
+ context->applyAllUpdates();
+ return;
}
+#endif
UpdateContextProps(context);
- context->mHoldUpdates.store(false, std::memory_order_release);
return;
}
context->mPropsDirty = true;
}
-#else
-
-inline void CommitAndUpdateProps(ALCcontext *context)
-{ UpdateProps(context); }
-#endif
-
} // namespace
AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value)
diff --git a/al/source.cpp b/al/source.cpp
index 4993a83c..17a3a0ae 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -3958,15 +3958,6 @@ SourceSubList::~SourceSubList()
#ifdef ALSOFT_EAX
-void EaxUpdateSourceVoice(ALsource *source, ALCcontext *context)
-{
- if(Voice *voice{GetSourceVoice(source, context)})
- {
- if(std::exchange(source->mPropsDirty, false))
- UpdateSourceProps(source, voice, context);
- }
-}
-
constexpr const ALsource::EaxFxSlotIds ALsource::eax4_fx_slot_ids;
constexpr const ALsource::EaxFxSlotIds ALsource::eax5_fx_slot_ids;
@@ -3988,12 +3979,6 @@ void ALsource::eax_dispatch(const EaxCall& call)
call.is_get() ? eax_get(call) : eax_set(call);
}
-void ALsource::eax_commit_and_update()
-{
- eax_commit();
- EaxUpdateSourceVoice(this, eax_al_context_);
-}
-
ALsource* ALsource::eax_lookup_source(ALCcontext& al_context, ALuint source_id) noexcept
{
return LookupSource(&al_context, source_id);
diff --git a/al/source.h b/al/source.h
index 78268781..9dffbff7 100644
--- a/al/source.h
+++ b/al/source.h
@@ -162,7 +162,6 @@ public:
void eax_initialize(ALCcontext *context) noexcept;
void eax_dispatch(const EaxCall& call);
void eax_commit();
- void eax_commit_and_update();
void eax_mark_as_changed() { eax_changed_ = true; }
static ALsource* eax_lookup_source(ALCcontext& al_context, ALuint source_id) noexcept;
diff --git a/alc/context.cpp b/alc/context.cpp
index 352db31d..b5a9b6f9 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -264,6 +264,11 @@ void ALCcontext::applyAllUpdates()
/* busy-wait */
}
+#ifdef ALSOFT_EAX
+ if(eax_needs_commit_)
+ eax_commit();
+#endif
+
if(std::exchange(mPropsDirty, false))
UpdateContextProps(this);
UpdateAllEffectSlotProps(this);
@@ -344,6 +349,7 @@ ALenum ALCcontext::eax_eax_set(
default:
eax_fail_unknown_property_set_id();
}
+ eax_needs_commit_ = true;
if(!call.is_deferred())
{
@@ -391,12 +397,6 @@ ALenum ALCcontext::eax_eax_get(
return AL_NO_ERROR;
}
-void ALCcontext::eax_commit_and_update_sources()
-{
- std::unique_lock<std::mutex> source_lock{mSourceLock};
- ForEachSource(this, std::mem_fn(&ALsource::eax_commit_and_update));
-}
-
void ALCcontext::eax_set_last_error() noexcept
{
eax_last_error_ = EAXERR_INVALID_OPERATION;
@@ -487,10 +487,6 @@ void ALCcontext::eax_initialize()
eax_initialize_fx_slots();
eax_is_initialized_ = true;
- mPropsDirty = true;
-
- if(!mDeferUpdates)
- applyAllUpdates();
}
bool ALCcontext::eax_has_no_default_effect_slot() const noexcept
@@ -997,6 +993,7 @@ void ALCcontext::eax_context_commit()
void ALCcontext::eax_commit()
{
+ eax_needs_commit_ = false;
eax_context_commit();
eax_commit_fx_slots();
eax_update_sources();
diff --git a/alc/context.h b/alc/context.h
index c0f1805c..941a3d80 100644
--- a/alc/context.h
+++ b/alc/context.h
@@ -204,7 +204,6 @@ public:
ALvoid* property_value,
ALuint property_value_size);
- void eax_commit_and_update_sources();
void eax_set_last_error() noexcept;
EaxFxSlotIndex eax_get_primary_fx_slot_index() const noexcept
@@ -215,6 +214,9 @@ public:
ALeffectslot& eax_get_fx_slot(EaxFxSlotIndexValue fx_slot_index)
{ return eax_fx_slots_.get(fx_slot_index); }
+ bool eax_needs_commit() const noexcept { return eax_needs_commit_; }
+ void eax_commit();
+
void eax_commit_fx_slots()
{ eax_fx_slots_.commit(); }
@@ -391,6 +393,7 @@ private:
EaxFxSlots eax_fx_slots_{};
int eax_version_{}; // Current EAX version.
+ bool eax_needs_commit_{};
EaxDirtyFlags eax_df_{}; // Dirty flags for the current EAX version.
Eax5State eax123_{}; // EAX1/EAX2/EAX3 state.
Eax4State eax4_{}; // EAX4 state.
@@ -477,8 +480,6 @@ private:
void eax_context_set_defaults();
void eax_set_defaults();
- void eax_initialize_sources();
-
void eax_dispatch_fx_slot(const EaxCall& call);
void eax_dispatch_source(const EaxCall& call);
@@ -507,7 +508,6 @@ private:
void eax4_context_commit(Eax4State& state, EaxDirtyFlags& dst_df);
void eax5_context_commit(Eax5State& state, EaxDirtyFlags& dst_df);
void eax_context_commit();
- void eax_commit();
#endif // ALSOFT_EAX
};