1 #ifndef AL_AUXEFFECTSLOT_H
2 #define AL_AUXEFFECTSLOT_H
11 #include "alc/device.h"
12 #include "alc/effects/base.h"
15 #include "core/effectslot.h"
16 #include "intrusive_ptr.h"
22 #include "eax/effect.h"
23 #include "eax/fx_slot_index.h"
31 enum class SlotState
: ALenum
{
39 bool AuxSendAuto
{true};
40 ALeffectslot
*Target
{nullptr};
41 ALbuffer
*Buffer
{nullptr};
44 EffectSlotType Type
{EffectSlotType::None
};
47 al::intrusive_ptr
<EffectState
> State
;
50 bool mPropsDirty
{true};
52 SlotState mState
{SlotState::Initial
};
62 ALeffectslot(const ALeffectslot
&) = delete;
63 ALeffectslot
& operator=(const ALeffectslot
&) = delete;
66 ALenum
initEffect(ALenum effectType
, const EffectProps
&effectProps
, ALCcontext
*context
);
67 void updateProps(ALCcontext
*context
);
69 /* This can be new'd for the context's default effect slot. */
70 DEF_NEWDEL(ALeffectslot
)
77 ALCcontext
& al_context
,
78 EaxFxSlotIndexValue index
);
80 const EAX50FXSLOTPROPERTIES
& eax_get_eax_fx_slot() const noexcept
;
84 bool eax_dispatch(const EaxCall
& call
)
85 { return call
.is_get() ? eax_get(call
) : eax_set(call
); }
88 void eax_unlock_legacy() noexcept
;
90 void eax_commit() { eax_apply_deferred(); }
93 ALCcontext
* eax_al_context_
{};
95 EaxFxSlotIndexValue eax_fx_slot_index_
{};
97 EAX50FXSLOTPROPERTIES eax_eax_fx_slot_
{};
99 EaxEffectUPtr eax_effect_
{};
100 bool eax_is_locked_
{};
104 static void eax_fail(
105 const char* message
);
108 GUID
eax_get_eax_default_effect_guid() const noexcept
;
109 long eax_get_eax_default_lock() const noexcept
;
111 void eax_set_eax_fx_slot_defaults();
113 void eax_initialize_eax();
115 void eax_initialize_lock();
118 void eax_initialize_effects(const EaxCall
& call
);
121 void eax_get_fx_slot_all(const EaxCall
& call
) const;
123 void eax_get_fx_slot(const EaxCall
& call
) const;
126 bool eax_get(const EaxCall
& call
);
129 void eax_set_fx_slot_effect(const EaxCall
& call
, ALenum effect_type
);
131 void eax_set_fx_slot_effect(const EaxCall
& call
);
134 void eax_set_efx_effect_slot_gain();
136 void eax_set_fx_slot_volume();
139 void eax_set_effect_slot_send_auto();
141 void eax_set_fx_slot_flags();
144 void eax_ensure_is_unlocked() const;
146 void eax_validate_fx_slot_effect(const GUID
& eax_effect_id
);
147 void eax_validate_fx_slot_volume(long eax_volume
);
148 void eax_validate_fx_slot_lock(long eax_lock
);
149 void eax_validate_fx_slot_flags(const EaxCall
& call
, unsigned long eax_flags
);
150 void eax_validate_fx_slot_occlusion(long eax_occlusion
);
151 void eax_validate_fx_slot_occlusion_lf_ratio(float eax_occlusion_lf_ratio
);
152 void eax_validate_fx_slot_all(const EaxCall
& call
, const EAX40FXSLOTPROPERTIES
& fx_slot
);
153 void eax_validate_fx_slot_all(const EaxCall
& call
, const EAX50FXSLOTPROPERTIES
& fx_slot
);
155 void eax_set_fx_slot_effect(const EaxCall
& call
, const GUID
& eax_effect_id
);
157 void eax_set_fx_slot_volume(
160 void eax_set_fx_slot_lock(
163 void eax_set_fx_slot_flags(
164 unsigned long eax_flags
);
167 bool eax_set_fx_slot_occlusion(
171 bool eax_set_fx_slot_occlusion_lf_ratio(
172 float eax_occlusion_lf_ratio
);
174 void eax_set_fx_slot_all(const EaxCall
& call
, const EAX40FXSLOTPROPERTIES
& eax_fx_slot
);
177 bool eax_set_fx_slot_all(const EaxCall
& call
, const EAX50FXSLOTPROPERTIES
& eax_fx_slot
);
180 void eax_defer_fx_slot_effect(const EaxCall
& call
);
182 void eax_defer_fx_slot_volume(const EaxCall
& call
);
184 void eax_defer_fx_slot_lock(const EaxCall
& call
);
186 void eax_defer_fx_slot_flags(const EaxCall
& call
);
189 bool eax_defer_fx_slot_occlusion(const EaxCall
& call
);
192 bool eax_defer_fx_slot_occlusion_lf_ratio(const EaxCall
& call
);
195 bool eax_defer_fx_slot_all(const EaxCall
& call
);
197 bool eax_set_fx_slot(const EaxCall
& call
);
199 void eax_apply_deferred();
202 bool eax_set(const EaxCall
& call
);
205 void eax_dispatch_effect(const EaxCall
& call
);
208 // `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_EFFECT, effect)`
209 void eax_set_effect_slot_effect(EaxEffect
&effect
);
211 // `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, value)`
212 void eax_set_effect_slot_send_auto(bool is_send_auto
);
214 // `alAuxiliaryEffectSlotf(effect_slot, AL_EFFECTSLOT_GAIN, gain)`
215 void eax_set_effect_slot_gain(ALfloat gain
);
220 void operator()(ALeffectslot
*effect_slot
);
221 }; // EaxAlEffectSlotDeleter
225 void UpdateAllEffectSlotProps(ALCcontext
*context
);
229 using EaxAlEffectSlotUPtr
= std::unique_ptr
<ALeffectslot
, ALeffectslot::EaxDeleter
>;
232 EaxAlEffectSlotUPtr
eax_create_al_effect_slot(
233 ALCcontext
& context
);
235 void eax_delete_al_effect_slot(
237 ALeffectslot
& effect_slot
);