aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-06-19 07:59:08 -0700
committerChris Robinson <[email protected]>2022-06-19 08:04:30 -0700
commitaf690871b13affba189362a59af7b941d7e4cea2 (patch)
tree91f21c06c7744f314dd0209285a73aaa0efe2fd8 /al
parenta6c099c63e87b4e3c91bbdcd102a3df2d4d05c8e (diff)
Combine multiple individual flags
Diffstat (limited to 'al')
-rw-r--r--al/effects/reverb.cpp86
-rw-r--r--al/source.cpp80
-rw-r--r--al/source.h6
3 files changed, 67 insertions, 105 deletions
diff --git a/al/effects/reverb.cpp b/al/effects/reverb.cpp
index 044430d4..a0e62da9 100644
--- a/al/effects/reverb.cpp
+++ b/al/effects/reverb.cpp
@@ -593,21 +593,18 @@ private:
struct State1
{
- bool changed{false};
Props1 i; // Immediate.
Props1 d; // Deferred.
}; // State1
struct State2
{
- bool changed{false};
Props2 i; // Immediate.
Props2 d; // Deferred.
}; // State2
struct State3
{
- bool changed{false};
Props3 i; // Immediate.
Props3 d; // Deferred.
}; // State3
@@ -1112,6 +1109,7 @@ private:
}; // EnvironmentSizeDeferrer3
int version_;
+ bool changed_{};
Props3 props_{};
State1 state1_{};
State2 state2_{};
@@ -1563,51 +1561,36 @@ void EaxReverbEffect::get(const EaxCall& call)
/*[[nodiscard]]*/ bool EaxReverbEffect::commit()
{
- if((version_ == 1 && !state1_.changed)
- || (version_ == 2 && !state2_.changed)
- || (version_ == 3 && !state3_.changed)
- || (version_ == 4 && !state4_.changed)
- || (version_ == 5 && !state5_.changed))
- {
+ if(!changed_)
return false;
- }
+ changed_ = false;
const auto props = props_;
-
- switch (version_)
+ switch(version_)
{
- case 1:
- state1_.changed = false;
- state1_.i = state1_.d;
- translate(state1_.d, props_);
- break;
-
- case 2:
- state2_.changed = false;
- state2_.i = state2_.d;
- translate(state2_.d, props_);
- break;
-
- case 3:
- state3_.changed = false;
- state3_.i = state3_.d;
- props_ = state3_.d;
- break;
-
- case 4:
- state4_.changed = false;
- state4_.i = state4_.d;
- props_ = state4_.d;
- break;
-
- case 5:
- state5_.changed = false;
- state5_.i = state5_.d;
- props_ = state5_.d;
- break;
+ case 1:
+ state1_.i = state1_.d;
+ translate(state1_.d, props_);
+ break;
+ case 2:
+ state2_.i = state2_.d;
+ translate(state2_.d, props_);
+ break;
+ case 3:
+ state3_.i = state3_.d;
+ props_ = state3_.d;
+ break;
+ case 4:
+ state4_.i = state4_.d;
+ props_ = state4_.d;
+ break;
+ case 5:
+ state5_.i = state5_.d;
+ props_ = state5_.d;
+ break;
- default:
- fail_unknown_version();
+ default:
+ fail_unknown_version();
}
auto is_dirty = false;
@@ -1953,17 +1936,16 @@ void EaxReverbEffect::set3(const EaxCall& call, Props3& props)
void EaxReverbEffect::set(const EaxCall& call)
{
const auto version = call.get_version();
-
- switch (version)
+ switch(version)
{
- case 1: set1(call, state1_.d); state1_.changed = true; break;
- case 2: set2(call, state2_.d); state2_.changed = true; break;
- case 3: set3(call, state3_.d); state3_.changed = true; break;
- case 4: set3(call, state4_.d); state4_.changed = true; break;
- case 5: set3(call, state5_.d); state5_.changed = true; break;
- default: fail_unknown_version();
+ case 1: set1(call, state1_.d); break;
+ case 2: set2(call, state2_.d); break;
+ case 3: set3(call, state3_.d); break;
+ case 4: set3(call, state4_.d); break;
+ case 5: set3(call, state5_.d); break;
+ default: fail_unknown_version();
}
-
+ changed_ = true;
version_ = version;
}
diff --git a/al/source.cpp b/al/source.cpp
index fd2d624b..e68c5b1e 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -4475,13 +4475,14 @@ void ALsource::eax_set(const EaxCall& call)
const auto eax_version = call.get_version();
switch(eax_version)
{
- case 1: eax1_set(call, eax1_.d); eax1_.changed = true; break;
- case 2: eax2_set(call, eax2_.d); eax2_.changed = true; break;
- case 3: eax3_set(call, eax3_.d); eax3_.changed = true; break;
- case 4: eax4_set(call, eax4_.d); eax4_.changed = true; break;
- case 5: eax5_set(call, eax5_.d); eax5_.changed = true; break;
- default: eax_fail_unknown_property_id();
+ case 1: eax1_set(call, eax1_.d); break;
+ case 2: eax2_set(call, eax2_.d); break;
+ case 3: eax3_set(call, eax3_.d); break;
+ case 4: eax4_set(call, eax4_.d); break;
+ case 5: eax5_set(call, eax5_.d); break;
+ default: eax_fail_unknown_property_id();
}
+ eax_changed_ = true;
eax_version_ = eax_version;
}
@@ -4894,54 +4895,37 @@ void ALsource::eax_commit(EaxCommitType commit_type)
const auto primary_fx_slot_id = eax_al_context_->eax_get_primary_fx_slot_index();
const auto is_primary_fx_slot_id_changed = (eax_primary_fx_slot_id_ != primary_fx_slot_id);
- const auto is_forced = is_primary_fx_slot_id_changed || commit_type == EaxCommitType::forced;
+ if(commit_type != EaxCommitType::forced && !is_primary_fx_slot_id_changed && !eax_changed_)
+ return;
eax_primary_fx_slot_id_ = primary_fx_slot_id;
+ eax_changed_ = false;
switch(eax_version_)
{
- case 1:
- if(!is_forced && !eax1_.changed)
- return;
- eax1_.changed = false;
- eax1_.i = eax1_.d;
- eax1_translate(eax1_.i, eax_);
- break;
-
- case 2:
- if(!is_forced && !eax2_.changed)
- return;
- eax2_.changed = false;
- eax2_.i = eax2_.d;
- eax2_translate(eax2_.i, eax_);
- break;
-
- case 3:
- if(!is_forced && !eax3_.changed)
- return;
- eax3_.changed = false;
- eax3_.i = eax3_.d;
- eax3_translate(eax3_.i, eax_);
- break;
-
- case 4:
- if(!is_forced && !eax4_.changed)
- return;
- eax4_.changed = false;
- eax4_.i = eax4_.d;
- eax4_translate(eax4_.i, eax_);
- break;
-
- case 5:
- if(!is_forced && !eax5_.changed)
- return;
- eax5_.changed = false;
- eax5_.i = eax5_.d;
- eax_ = eax5_.d;
- break;
+ case 1:
+ eax1_.i = eax1_.d;
+ eax1_translate(eax1_.i, eax_);
+ break;
+ case 2:
+ eax2_.i = eax2_.d;
+ eax2_translate(eax2_.i, eax_);
+ break;
+ case 3:
+ eax3_.i = eax3_.d;
+ eax3_translate(eax3_.i, eax_);
+ break;
+ case 4:
+ eax4_.i = eax4_.d;
+ eax4_translate(eax4_.i, eax_);
+ break;
+ case 5:
+ eax5_.i = eax5_.d;
+ eax_ = eax5_.d;
+ break;
- default:
- eax_fail_unknown_version();
+ default:
+ eax_fail_unknown_version();
}
eax_set_efx_outer_gain_hf();
diff --git a/al/source.h b/al/source.h
index 5bfa6616..a1efd527 100644
--- a/al/source.h
+++ b/al/source.h
@@ -200,7 +200,6 @@ private:
using Eax1Props = EAXBUFFER_REVERBPROPERTIES;
struct Eax1State {
- bool changed{false};
Eax1Props i; // Immediate.
Eax1Props d; // Deferred.
};
@@ -208,7 +207,6 @@ private:
using Eax2Props = EAX20BUFFERPROPERTIES;
struct Eax2State {
- bool changed{false};
Eax2Props i; // Immediate.
Eax2Props d; // Deferred.
};
@@ -216,7 +214,6 @@ private:
using Eax3Props = EAX30SOURCEPROPERTIES;
struct Eax3State {
- bool changed{false};
Eax3Props i; // Immediate.
Eax3Props d; // Deferred.
};
@@ -233,7 +230,6 @@ private:
};
struct Eax4State {
- bool changed{false};
Eax4Props i; // Immediate.
Eax4Props d; // Deferred.
};
@@ -251,7 +247,6 @@ private:
};
struct Eax5State {
- bool changed{false};
Eax5Props i; // Immediate.
Eax5Props d; // Deferred.
};
@@ -260,6 +255,7 @@ private:
EaxFxSlotIndex eax_primary_fx_slot_id_{};
EaxActiveFxSlots eax_active_fx_slots_{};
int eax_version_{};
+ bool eax_changed_{};
Eax1State eax1_{};
Eax2State eax2_{};
Eax3State eax3_{};