Don't handle EFX functions in the router
[openal-soft.git] / al / auxeffectslot.h
blobd845b2b460b8a79d8925d7ffc11f0e4471bc26d4
1 #ifndef AL_AUXEFFECTSLOT_H
2 #define AL_AUXEFFECTSLOT_H
4 #include <atomic>
5 #include <cstddef>
7 #include "AL/al.h"
8 #include "AL/alc.h"
9 #include "AL/efx.h"
11 #include "alc/device.h"
12 #include "alc/effects/base.h"
13 #include "almalloc.h"
14 #include "atomic.h"
15 #include "core/effectslot.h"
16 #include "intrusive_ptr.h"
17 #include "vector.h"
19 #ifdef ALSOFT_EAX
20 #include <memory>
22 #include "eax_eax_call.h"
23 #include "eax_effect.h"
24 #include "eax_fx_slot_index.h"
25 #endif // ALSOFT_EAX
27 struct ALbuffer;
28 struct ALeffect;
29 struct WetBuffer;
32 enum class SlotState : ALenum {
33 Initial = AL_INITIAL,
34 Playing = AL_PLAYING,
35 Stopped = AL_STOPPED,
38 struct ALeffectslot {
39 float Gain{1.0f};
40 bool AuxSendAuto{true};
41 ALeffectslot *Target{nullptr};
42 ALbuffer *Buffer{nullptr};
44 struct {
45 EffectSlotType Type{EffectSlotType::None};
46 EffectProps Props{};
48 al::intrusive_ptr<EffectState> State;
49 } Effect;
51 bool mPropsDirty{true};
53 SlotState mState{SlotState::Initial};
55 RefCount ref{0u};
57 EffectSlot mSlot;
59 /* Self ID */
60 ALuint id{};
62 ALeffectslot();
63 ALeffectslot(const ALeffectslot&) = delete;
64 ALeffectslot& operator=(const ALeffectslot&) = delete;
65 ~ALeffectslot();
67 ALenum initEffect(ALenum effectType, const EffectProps &effectProps, ALCcontext *context);
68 void updateProps(ALCcontext *context);
70 /* This can be new'd for the context's default effect slot. */
71 DEF_NEWDEL(ALeffectslot)
74 #ifdef ALSOFT_EAX
75 public:
76 void eax_initialize(
77 ALCcontext& al_context,
78 EaxFxSlotIndexValue index);
81 const EAX50FXSLOTPROPERTIES& eax_get_eax_fx_slot() const noexcept;
84 // [[nodiscard]]
85 bool eax_dispatch(
86 const EaxEaxCall& eax_call);
88 void eax_unlock_legacy() noexcept;
91 private:
92 ALCcontext* eax_al_context_{};
94 EaxFxSlotIndexValue eax_fx_slot_index_{};
96 EAX50FXSLOTPROPERTIES eax_eax_fx_slot_{};
98 EaxEffectUPtr eax_effect_{};
99 bool eax_is_locked_{};
102 [[noreturn]]
103 static void eax_fail(
104 const char* message);
107 GUID eax_get_eax_default_effect_guid() const noexcept;
108 long eax_get_eax_default_lock() const noexcept;
110 void eax_set_eax_fx_slot_defaults();
112 void eax_initialize_eax();
114 void eax_initialize_lock();
117 void eax_initialize_effects();
120 void eax_get_fx_slot_all(
121 const EaxEaxCall& eax_call) const;
123 void eax_get_fx_slot(
124 const EaxEaxCall& eax_call) const;
126 // [[nodiscard]]
127 bool eax_get(
128 const EaxEaxCall& eax_call);
131 void eax_set_fx_slot_effect(
132 ALenum effect_type);
134 void eax_set_fx_slot_effect();
137 void eax_set_efx_effect_slot_gain();
139 void eax_set_fx_slot_volume();
142 void eax_set_effect_slot_send_auto();
144 void eax_set_fx_slot_flags();
147 void eax_ensure_is_unlocked() const;
150 void eax_validate_fx_slot_effect(
151 const GUID& eax_effect_id);
153 void eax_validate_fx_slot_volume(
154 long eax_volume);
156 void eax_validate_fx_slot_lock(
157 long eax_lock);
159 void eax_validate_fx_slot_flags(
160 unsigned long eax_flags,
161 int eax_version);
163 void eax_validate_fx_slot_occlusion(
164 long eax_occlusion);
166 void eax_validate_fx_slot_occlusion_lf_ratio(
167 float eax_occlusion_lf_ratio);
169 void eax_validate_fx_slot_all(
170 const EAX40FXSLOTPROPERTIES& fx_slot,
171 int eax_version);
173 void eax_validate_fx_slot_all(
174 const EAX50FXSLOTPROPERTIES& fx_slot,
175 int eax_version);
178 void eax_set_fx_slot_effect(
179 const GUID& eax_effect_id);
181 void eax_set_fx_slot_volume(
182 long eax_volume);
184 void eax_set_fx_slot_lock(
185 long eax_lock);
187 void eax_set_fx_slot_flags(
188 unsigned long eax_flags);
190 // [[nodiscard]]
191 bool eax_set_fx_slot_occlusion(
192 long eax_occlusion);
194 // [[nodiscard]]
195 bool eax_set_fx_slot_occlusion_lf_ratio(
196 float eax_occlusion_lf_ratio);
198 void eax_set_fx_slot_all(
199 const EAX40FXSLOTPROPERTIES& eax_fx_slot);
201 // [[nodiscard]]
202 bool eax_set_fx_slot_all(
203 const EAX50FXSLOTPROPERTIES& eax_fx_slot);
206 void eax_set_fx_slot_effect(
207 const EaxEaxCall& eax_call);
209 void eax_set_fx_slot_volume(
210 const EaxEaxCall& eax_call);
212 void eax_set_fx_slot_lock(
213 const EaxEaxCall& eax_call);
215 void eax_set_fx_slot_flags(
216 const EaxEaxCall& eax_call);
218 // [[nodiscard]]
219 bool eax_set_fx_slot_occlusion(
220 const EaxEaxCall& eax_call);
222 // [[nodiscard]]
223 bool eax_set_fx_slot_occlusion_lf_ratio(
224 const EaxEaxCall& eax_call);
226 // [[nodiscard]]
227 bool eax_set_fx_slot_all(
228 const EaxEaxCall& eax_call);
230 bool eax_set_fx_slot(
231 const EaxEaxCall& eax_call);
233 // [[nodiscard]]
234 bool eax_set(
235 const EaxEaxCall& eax_call);
238 void eax_dispatch_effect(
239 const EaxEaxCall& eax_call);
242 // `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_EFFECT, effect)`
243 void eax_set_effect_slot_effect(EaxEffect &effect);
245 // `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, value)`
246 void eax_set_effect_slot_send_auto(bool is_send_auto);
248 // `alAuxiliaryEffectSlotf(effect_slot, AL_EFFECTSLOT_GAIN, gain)`
249 void eax_set_effect_slot_gain(ALfloat gain);
250 #endif // ALSOFT_EAX
253 void UpdateAllEffectSlotProps(ALCcontext *context);
255 #ifdef ALSOFT_EAX
256 class EaxAlEffectSlotDeleter
258 public:
259 EaxAlEffectSlotDeleter() noexcept = default;
261 EaxAlEffectSlotDeleter(
262 ALCcontext& context) noexcept;
264 void operator()(
265 ALeffectslot* effect_slot);
268 private:
269 ALCcontext* context_{};
270 }; // EaxAlEffectSlotDeleter
272 using EaxAlEffectSlotUPtr = std::unique_ptr<ALeffectslot, EaxAlEffectSlotDeleter>;
275 EaxAlEffectSlotUPtr eax_create_al_effect_slot(
276 ALCcontext& context);
278 void eax_delete_al_effect_slot(
279 ALCcontext& context,
280 ALeffectslot& effect_slot);
281 #endif // ALSOFT_EAX
283 #endif