aboutsummaryrefslogtreecommitdiffstats
path: root/al/auxeffectslot.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-02-07 10:17:13 -0800
committerChris Robinson <[email protected]>2022-02-07 10:17:13 -0800
commit0c507b5c621993206d94fc3776174eb96823f265 (patch)
tree27ce2550c88fb9f73145fd8be2298850814985bc /al/auxeffectslot.cpp
parentb09aab8426b0feb74cacb8704b4953b3b56a8c30 (diff)
Avoid using ALeffect to manage EaxEffect objects
Effect slots can just use its EaxEffect directly.
Diffstat (limited to 'al/auxeffectslot.cpp')
-rw-r--r--al/auxeffectslot.cpp53
1 files changed, 11 insertions, 42 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index e0f2be73..5ddd2a28 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -1091,11 +1091,6 @@ void ALeffectslot::eax_initialize(
eax_set_default_slots_defaults();
}
-void ALeffectslot::eax_uninitialize() noexcept
-{
- eax_al_effect_ = nullptr;
-}
-
const EAX50FXSLOTPROPERTIES& ALeffectslot::eax_get_eax_fx_slot() const noexcept
{
return eax_eax_fx_slot_;
@@ -1436,21 +1431,13 @@ bool ALeffectslot::eax_get(
void ALeffectslot::eax_set_fx_slot_effect(
ALenum al_effect_type)
{
- if (!eax_al_effect_)
- {
- eax_al_effect_ = eax_create_al_effect(*eax_al_context_, al_effect_type);
- }
- else
- {
- auto& device = eax_al_context_->mALDevice;
- std::lock_guard<std::mutex> effect_lock{device->EffectLock};
-
- eax_al_effect_->eax_al_set_effect(al_effect_type);
- }
+ if(!IsValidEffectType(al_effect_type))
+ eax_fail("Unsupported effect.");
- eax_al_effect_->eax_initialize();
+ eax_effect_ = nullptr;
+ eax_effect_ = eax_create_eax_effect(al_effect_type);
- eax_set_effect_slot_effect(*eax_al_effect_);
+ eax_set_effect_slot_effect(*eax_effect_);
}
void ALeffectslot::eax_set_fx_slot_effect()
@@ -1704,35 +1691,17 @@ void ALeffectslot::eax_dispatch_effect(
const EaxEaxCall& eax_call)
{
auto is_changed = false;
-
- {
- std::lock_guard<std::mutex> effect_lock{eax_al_context_->mALDevice->EffectLock};
-
- if (!eax_al_effect_->eax_effect)
- {
- return;
- }
-
- is_changed = eax_al_effect_->eax_effect->dispatch(eax_call);
- }
-
- if (is_changed)
- {
- eax_set_effect_slot_effect(*eax_al_effect_);
- }
+ if(eax_effect_)
+ is_changed = eax_effect_->dispatch(eax_call);
+ if(is_changed)
+ eax_set_effect_slot_effect(*eax_effect_);
}
-void ALeffectslot::eax_set_effect_slot_effect(
- ALeffect& effect)
+void ALeffectslot::eax_set_effect_slot_effect(EaxEffect &effect)
{
#define EAX_PREFIX "[EAX_SET_EFFECT_SLOT_EFFECT] "
- auto& device = *eax_al_context_->mALDevice;
-
- std::lock_guard<std::mutex> effect_slot_lock{eax_al_context_->mEffectSlotLock};
- std::lock_guard<std::mutex> effect_lock{device.EffectLock};
-
- const auto error = initEffect(effect.type, effect.Props, eax_al_context_);
+ const auto error = initEffect(effect.al_effect_type_, effect.al_effect_props_, eax_al_context_);
if (error != AL_NO_ERROR)
{
ERR(EAX_PREFIX "%s\n", "Failed to initialize an effect.");