diff --git a/include/Effects/EnvEffects.hpp b/include/Effects/EnvEffects.hpp index 83c44f1..cb2f6a6 100644 --- a/include/Effects/EnvEffects.hpp +++ b/include/Effects/EnvEffects.hpp @@ -14,13 +14,13 @@ namespace MetaAudio struct effectSlot { - alure::AuxiliaryEffectSlot slot; - alure::Effect effect; + alure::AutoObj slot; + alure::AutoObj effect; GainFading gain; - effectSlot(alure::AuxiliaryEffectSlot _slot, alure::Effect _effect) + effectSlot(alure::AuxiliaryEffectSlot slot, alure::Effect effect) + : slot(alure::MakeAuto(slot)), + effect(alure::MakeAuto(effect)) { - slot = _slot; - effect = _effect; }; }; @@ -82,7 +82,6 @@ namespace MetaAudio public: EnvEffects(alure::Context& al_context, ALCuint max_sends, std::shared_ptr occlusion_calculator); - ~EnvEffects(); void InterplEffect(int roomtype); void ApplyEffect(aud_channel_t* ch, qboolean underwater); diff --git a/src/Effects/EnvEffects.cpp b/src/Effects/EnvEffects.cpp index 8fdcc2b..a6610be 100644 --- a/src/Effects/EnvEffects.cpp +++ b/src/Effects/EnvEffects.cpp @@ -80,18 +80,18 @@ namespace MetaAudio alAuxEffectSlots[effect_slot].gain.target = AL_REVERBMIX; FadeToNewValue(true, false, alAuxEffectSlots[effect_slot].gain); - alAuxEffectSlots[effect_slot].effect.setReverbProperties(desired); + alAuxEffectSlots[effect_slot].effect->setReverbProperties(desired); } } else if (alAuxEffectSlots.size() == 1) { - alAuxEffectSlots[0].effect.setReverbProperties(desired); + alAuxEffectSlots[0].effect->setReverbProperties(desired); } for (auto& effectSlot : alAuxEffectSlots) { - effectSlot.slot.setGain(effectSlot.gain.current); - effectSlot.slot.applyEffect(effectSlot.effect); + effectSlot.slot->setGain(effectSlot.gain.current); + effectSlot.slot->applyEffect(effectSlot.effect.get()); } } @@ -177,7 +177,7 @@ namespace MetaAudio for (size_t i = 0; i < alAuxEffectSlots.size(); ++i) { - ch->sound_source->SetAuxiliarySendFilter(alAuxEffectSlots[i].slot, i, params); + ch->sound_source->SetAuxiliarySendFilter(alAuxEffectSlots[i].slot.get(), i, params); } } @@ -211,7 +211,7 @@ namespace MetaAudio if (alAuxEffectSlots.size() > 0) { - alAuxEffectSlots[0].slot.setGain(AL_REVERBMIX); + alAuxEffectSlots[0].slot->setGain(AL_REVERBMIX); alAuxEffectSlots[0].gain.current = AL_REVERBMIX; alAuxEffectSlots[0].gain.initial_value = AL_REVERBMIX; alAuxEffectSlots[0].gain.last_target = AL_REVERBMIX; @@ -219,7 +219,7 @@ namespace MetaAudio if (alAuxEffectSlots.size() > 1) { - alAuxEffectSlots[1].slot.setGain(0.0f); + alAuxEffectSlots[1].slot->setGain(0.0f); } } @@ -385,13 +385,4 @@ namespace MetaAudio } } } - - EnvEffects::~EnvEffects() - { - for (auto& effectSlot : alAuxEffectSlots) - { - effectSlot.slot.destroy(); - effectSlot.effect.destroy(); - } - } } \ No newline at end of file