aboutsummaryrefslogtreecommitdiffstats
path: root/al/effects/null.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-03-10 19:58:45 -0800
committerChris Robinson <[email protected]>2023-03-10 19:58:45 -0800
commit8c3948c4de4b84805664775bbfe64516e1100ad9 (patch)
treec3325fe665867cf225d7aa1c8dde4b0b35c7576b /al/effects/null.cpp
parent605fa7815948cdef42877286f85cc23ed5b3760d (diff)
Rework EAX effect handling
Allocate a base EaxEffect object once for all effect types, instead of reallocating different derived types on effect changes. The reverb and null effects have been converted to the new interface, the others are currently broken/unsupported, but will be restored shortly.
Diffstat (limited to 'al/effects/null.cpp')
-rw-r--r--al/effects/null.cpp66
1 files changed, 26 insertions, 40 deletions
diff --git a/al/effects/null.cpp b/al/effects/null.cpp
index 8b11f20c..e80ab9f8 100644
--- a/al/effects/null.cpp
+++ b/al/effects/null.cpp
@@ -100,64 +100,50 @@ const EffectProps NullEffectProps{genDefaultProps()};
#ifdef ALSOFT_EAX
namespace {
-class EaxNullEffectException : public EaxException
-{
-public:
- explicit EaxNullEffectException(const char* message)
- : EaxException{"EAX_NULL_EFFECT", message}
- {}
-}; // EaxNullEffectException
-
-class EaxNullEffect final : public EaxEffect4<EaxNullEffectException>
-{
-public:
- EaxNullEffect(int eax_version);
-
-private:
- void set_defaults(Props4& props) override;
-
- void set_efx_defaults() override;
+using NullCommitter = EaxCommitter<EaxNullCommitter>;
- void get(const EaxCall& call, const Props4& props) override;
- void set(const EaxCall& call, Props4& props) override;
- bool commit_props(const Props4& props) override;
-}; // EaxCompressorEffect
+} // namespace
-EaxNullEffect::EaxNullEffect(int eax_version)
- : EaxEffect4{AL_EFFECT_NULL, eax_version}
-{}
+template<>
+struct NullCommitter::Exception : public EaxException
+{
+ explicit Exception(const char *message) : EaxException{"EAX_NULL_EFFECT", message}
+ { }
+};
-void EaxNullEffect::set_defaults(Props4& props)
+template<>
+[[noreturn]] void NullCommitter::fail(const char *message)
{
- props.mType = EaxEffectType::None;
+ throw Exception{message};
}
-void EaxNullEffect::set_efx_defaults()
+template<>
+bool NullCommitter::commit(const EaxEffectProps &props)
{
+ const bool ret{props.mType != props_.mType};
+ props_ = props;
+ return ret;
}
-void EaxNullEffect::get(const EaxCall& call, const Props4&)
+template<>
+void NullCommitter::SetDefaults(EaxEffectProps &props)
{
- if(call.get_property_id() != 0)
- fail_unknown_property_id();
+ props = EaxEffectProps{};
+ props.mType = EaxEffectType::None;
}
-void EaxNullEffect::set(const EaxCall& call, Props4&)
+template<>
+void NullCommitter::Get(const EaxCall &call, const EaxEffectProps&)
{
if(call.get_property_id() != 0)
fail_unknown_property_id();
}
-bool EaxNullEffect::commit_props(const Props4&)
+template<>
+void NullCommitter::Set(const EaxCall &call, EaxEffectProps&)
{
- return false;
-}
-
-} // namespace
-
-EaxEffectUPtr eax_create_eax_null_effect(int eax_version)
-{
- return std::make_unique<EaxNullEffect>(eax_version);
+ if(call.get_property_id() != 0)
+ fail_unknown_property_id();
}
#endif // ALSOFT_EAX