diff options
Diffstat (limited to 'al')
-rw-r--r-- | al/auxeffectslot.cpp | 58 | ||||
-rw-r--r-- | al/auxeffectslot.h | 4 | ||||
-rw-r--r-- | al/eax_effect.h | 3 | ||||
-rw-r--r-- | al/eax_fx_slots.h | 6 | ||||
-rw-r--r-- | al/effects/autowah.cpp | 5 | ||||
-rw-r--r-- | al/effects/chorus.cpp | 10 | ||||
-rw-r--r-- | al/effects/compressor.cpp | 5 | ||||
-rw-r--r-- | al/effects/distortion.cpp | 5 | ||||
-rw-r--r-- | al/effects/echo.cpp | 4 | ||||
-rw-r--r-- | al/effects/equalizer.cpp | 5 | ||||
-rw-r--r-- | al/effects/fshifter.cpp | 5 | ||||
-rw-r--r-- | al/effects/modulator.cpp | 5 | ||||
-rw-r--r-- | al/effects/null.cpp | 8 | ||||
-rw-r--r-- | al/effects/pshifter.cpp | 6 | ||||
-rw-r--r-- | al/effects/reverb.cpp | 6 | ||||
-rw-r--r-- | al/effects/vmorpher.cpp | 6 |
16 files changed, 84 insertions, 57 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 50c5cda6..bb279c88 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -1023,14 +1023,18 @@ void ALeffectslot::updateProps(ALCcontext *context) void UpdateAllEffectSlotProps(ALCcontext *context) { std::lock_guard<std::mutex> _{context->mEffectSlotLock}; +#ifdef ALSOFT_EAX + if(context->has_eax()) + context->eax_commit_fx_slots(); +#endif for(auto &sublist : context->mEffectSlotList) { uint64_t usemask{~sublist.FreeMask}; while(usemask) { const int idx{al::countr_zero(usemask)}; - ALeffectslot *slot{sublist.EffectSlots + idx}; usemask &= ~(1_u64 << idx); + ALeffectslot *slot{sublist.EffectSlots + idx}; if(slot->mState != SlotState::Stopped && std::exchange(slot->mPropsDirty, false)) slot->updateProps(context); @@ -1676,18 +1680,28 @@ bool ALeffectslot::eax_set_fx_slot( bool ALeffectslot::eax_set( const EaxEaxCall& eax_call) { + bool ret{false}; + switch (eax_call.get_property_set_id()) { case EaxEaxCallPropertySetId::fx_slot: - return eax_set_fx_slot(eax_call); + ret = eax_set_fx_slot(eax_call); + break; case EaxEaxCallPropertySetId::fx_slot_effect: eax_dispatch_effect(eax_call); - return false; + break; default: eax_fail("Unsupported property id."); } + + if(!eax_call.is_deferred()) + { + eax_apply_deferred(); + } + + return ret; } void ALeffectslot::eax_dispatch_effect( @@ -1700,6 +1714,18 @@ void ALeffectslot::eax_dispatch_effect( eax_set_effect_slot_effect(*eax_effect_); } +void ALeffectslot::eax_apply_deferred() +{ + /* The other FXSlot properties (volume, effect, etc) aren't deferred? */ + + auto is_changed = false; + if(eax_effect_) + is_changed = eax_effect_->apply_deferred(); + if(is_changed) + eax_set_effect_slot_effect(*eax_effect_); +} + + void ALeffectslot::eax_set_effect_slot_effect(EaxEffect &effect) { #define EAX_PREFIX "[EAX_SET_EFFECT_SLOT_EFFECT] " @@ -1732,14 +1758,11 @@ void ALeffectslot::eax_set_effect_slot_effect(EaxEffect &effect) void ALeffectslot::eax_set_effect_slot_send_auto( bool is_send_auto) { - std::lock_guard<std::mutex> effect_slot_lock{eax_al_context_->mEffectSlotLock}; - - const auto is_changed = (AuxSendAuto != is_send_auto); + if(AuxSendAuto == is_send_auto) + return; AuxSendAuto = is_send_auto; - - if (is_changed) - UpdateProps(this, eax_al_context_); + UpdateProps(this, eax_al_context_); } void ALeffectslot::eax_set_effect_slot_gain( @@ -1747,20 +1770,13 @@ void ALeffectslot::eax_set_effect_slot_gain( { #define EAX_PREFIX "[EAX_SET_EFFECT_SLOT_GAIN] " - if (gain < 0.0F || gain > 1.0F) - { - ERR(EAX_PREFIX "%s\n", "Gain out of range."); + if(gain == Gain) return; - } - - std::lock_guard<std::mutex> effect_slot_lock{eax_al_context_->mEffectSlotLock}; + if(gain < 0.0f || gain > 1.0f) + ERR(EAX_PREFIX "Gain out of range (%f)\n", gain); - const auto is_changed = (Gain != gain); - - Gain = gain; - - if (is_changed) - UpdateProps(this, eax_al_context_); + Gain = clampf(gain, 0.0f, 1.0f); + UpdateProps(this, eax_al_context_); #undef EAX_PREFIX } diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index d845b2b4..94a61cfc 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -77,7 +77,6 @@ public: ALCcontext& al_context, EaxFxSlotIndexValue index); - const EAX50FXSLOTPROPERTIES& eax_get_eax_fx_slot() const noexcept; @@ -87,6 +86,7 @@ public: void eax_unlock_legacy() noexcept; + void eax_commit() { eax_apply_deferred(); } private: ALCcontext* eax_al_context_{}; @@ -230,6 +230,8 @@ private: bool eax_set_fx_slot( const EaxEaxCall& eax_call); + void eax_apply_deferred(); + // [[nodiscard]] bool eax_set( const EaxEaxCall& eax_call); diff --git a/al/eax_effect.h b/al/eax_effect.h index 1ce41647..6de9afcc 100644 --- a/al/eax_effect.h +++ b/al/eax_effect.h @@ -21,6 +21,9 @@ public: // [[nodiscard]] virtual bool dispatch( const EaxEaxCall& eax_call) = 0; + + // [[nodiscard]] + virtual bool apply_deferred() = 0; }; // EaxEffect diff --git a/al/eax_fx_slots.h b/al/eax_fx_slots.h index 0ebb9b7d..a104c6ab 100644 --- a/al/eax_fx_slots.h +++ b/al/eax_fx_slots.h @@ -19,6 +19,12 @@ public: void uninitialize() noexcept; + void commit() + { + for(auto& fx_slot : fx_slots_) + fx_slot->eax_commit(); + } + const ALeffectslot& get( EaxFxSlotIndex index) const; diff --git a/al/effects/autowah.cpp b/al/effects/autowah.cpp index 51f8fff6..6fa859ba 100644 --- a/al/effects/autowah.cpp +++ b/al/effects/autowah.cpp @@ -143,6 +143,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXAUTOWAHPROPERTIES eax_{}; @@ -217,9 +219,6 @@ private: const EaxEaxCall& eax_call); // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxAutoWahEffect diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp index 15b9d635..397b338a 100644 --- a/al/effects/chorus.cpp +++ b/al/effects/chorus.cpp @@ -364,6 +364,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXCHORUSPROPERTIES eax_{}; @@ -461,9 +463,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxChorusEffect @@ -949,6 +948,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXFLANGERPROPERTIES eax_{}; @@ -1046,9 +1047,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxFlangerEffect diff --git a/al/effects/compressor.cpp b/al/effects/compressor.cpp index d4a8e9c2..cd284383 100644 --- a/al/effects/compressor.cpp +++ b/al/effects/compressor.cpp @@ -102,6 +102,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXAGCCOMPRESSORPROPERTIES eax_{}; @@ -144,9 +146,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxCompressorEffect diff --git a/al/effects/distortion.cpp b/al/effects/distortion.cpp index 4554901c..0f4b6ed5 100644 --- a/al/effects/distortion.cpp +++ b/al/effects/distortion.cpp @@ -148,6 +148,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXDISTORTIONPROPERTIES eax_{}; @@ -234,9 +236,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxDistortionEffect diff --git a/al/effects/echo.cpp b/al/effects/echo.cpp index f54e4f31..b2e45091 100644 --- a/al/effects/echo.cpp +++ b/al/effects/echo.cpp @@ -145,6 +145,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXECHOPROPERTIES eax_{}; @@ -230,8 +232,6 @@ private: const EaxEaxCall& eax_call); - bool apply_deferred(); - bool set( const EaxEaxCall& eax_call); }; // EaxEchoEffect diff --git a/al/effects/equalizer.cpp b/al/effects/equalizer.cpp index 43597972..8cd59cd1 100644 --- a/al/effects/equalizer.cpp +++ b/al/effects/equalizer.cpp @@ -208,6 +208,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXEQUALIZERPROPERTIES eax_{}; @@ -349,9 +351,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxEqualizerEffect diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp index 0100a864..8ad48ab3 100644 --- a/al/effects/fshifter.cpp +++ b/al/effects/fshifter.cpp @@ -164,6 +164,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXFREQUENCYSHIFTERPROPERTIES eax_{}; @@ -228,9 +230,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxFrequencyShifterEffect diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp index ec7520e2..a1521d26 100644 --- a/al/effects/modulator.cpp +++ b/al/effects/modulator.cpp @@ -170,6 +170,8 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; private: EAXRINGMODULATORPROPERTIES eax_{}; @@ -234,9 +236,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxRingModulatorEffect diff --git a/al/effects/null.cpp b/al/effects/null.cpp index 78c0a61a..5602280b 100644 --- a/al/effects/null.cpp +++ b/al/effects/null.cpp @@ -109,6 +109,9 @@ public: // [[nodiscard]] bool dispatch( const EaxEaxCall& eax_call) override; + + // [[nodiscard]] + bool apply_deferred() override; }; // EaxNullEffect @@ -142,6 +145,11 @@ bool EaxNullEffect::dispatch( return false; } +bool EaxNullEffect::apply_deferred() +{ + return false; +} + } // namespace EaxEffectUPtr eax_create_eax_null_effect() diff --git a/al/effects/pshifter.cpp b/al/effects/pshifter.cpp index 6c45ab4e..a2b06078 100644 --- a/al/effects/pshifter.cpp +++ b/al/effects/pshifter.cpp @@ -114,6 +114,9 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; + private: EAXPITCHSHIFTERPROPERTIES eax_{}; EAXPITCHSHIFTERPROPERTIES eax_d_{}; @@ -166,9 +169,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxPitchShifterEffect diff --git a/al/effects/reverb.cpp b/al/effects/reverb.cpp index 46fa0256..18760b5b 100644 --- a/al/effects/reverb.cpp +++ b/al/effects/reverb.cpp @@ -610,6 +610,9 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; + private: EAX_REVERBPROPERTIES eax1_{}; EAXREVERBPROPERTIES eax_{}; @@ -933,9 +936,6 @@ private: bool v1_set(const EaxEaxCall& eax_call); // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxReverbEffect diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp index 3081201c..15f099b1 100644 --- a/al/effects/vmorpher.cpp +++ b/al/effects/vmorpher.cpp @@ -285,6 +285,9 @@ public: bool dispatch( const EaxEaxCall& eax_call) override; + // [[nodiscard]] + bool apply_deferred() override; + private: EAXVOCALMORPHERPROPERTIES eax_{}; EAXVOCALMORPHERPROPERTIES eax_d_{}; @@ -381,9 +384,6 @@ private: // [[nodiscard]] - bool apply_deferred(); - - // [[nodiscard]] bool set( const EaxEaxCall& eax_call); }; // EaxVocalMorpherEffect |