Cast the ringbuffer size to the correct type
[openal-soft.git] / al / auxeffectslot.h
blobfdab99ef456e4240dcd534bdb767bbbafb72c8a3
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 "alcmain.h"
12 #include "almalloc.h"
13 #include "atomic.h"
14 #include "effects/base.h"
15 #include "intrusive_ptr.h"
16 #include "vector.h"
18 struct ALbuffer;
19 struct ALeffect;
20 struct ALeffectslot;
23 using ALeffectslotArray = al::FlexArray<ALeffectslot*>;
26 struct ALeffectslotProps {
27 float Gain;
28 bool AuxSendAuto;
29 ALeffectslot *Target;
31 ALenum Type;
32 EffectProps Props;
34 al::intrusive_ptr<EffectState> State;
36 std::atomic<ALeffectslotProps*> next;
38 DEF_NEWDEL(ALeffectslotProps)
42 enum class SlotState : ALenum {
43 Initial = AL_INITIAL,
44 Playing = AL_PLAYING,
45 Stopped = AL_STOPPED,
48 struct ALeffectslot {
49 float Gain{1.0f};
50 bool AuxSendAuto{true};
51 ALeffectslot *Target{nullptr};
52 ALbuffer *Buffer{nullptr};
54 struct {
55 ALenum Type{AL_EFFECT_NULL};
56 EffectProps Props{};
58 al::intrusive_ptr<EffectState> State;
59 } Effect;
61 std::atomic_flag PropsClean;
63 SlotState mState{SlotState::Initial};
65 RefCount ref{0u};
67 struct {
68 std::atomic<ALeffectslotProps*> Update{nullptr};
70 float Gain{1.0f};
71 bool AuxSendAuto{true};
72 ALeffectslot *Target{nullptr};
74 ALenum EffectType{AL_EFFECT_NULL};
75 EffectProps mEffectProps{};
76 EffectState *mEffectState{nullptr};
78 float RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */
79 float DecayTime{0.0f};
80 float DecayLFRatio{0.0f};
81 float DecayHFRatio{0.0f};
82 bool DecayHFLimit{false};
83 float AirAbsorptionGainHF{1.0f};
84 } Params;
86 /* Self ID */
87 ALuint id{};
89 /* Mixing buffer used by the Wet mix. */
90 al::vector<FloatBufferLine, 16> MixBuffer;
92 /* Wet buffer configuration is ACN channel order with N3D scaling.
93 * Consequently, effects that only want to work with mono input can use
94 * channel 0 by itself. Effects that want multichannel can process the
95 * ambisonics signal and make a B-Format source pan.
97 MixParams Wet;
99 ALeffectslot() { PropsClean.test_and_set(std::memory_order_relaxed); }
100 ALeffectslot(const ALeffectslot&) = delete;
101 ALeffectslot& operator=(const ALeffectslot&) = delete;
102 ~ALeffectslot();
104 ALenum init();
105 ALenum initEffect(ALeffect *effect, ALCcontext *context);
106 void updateProps(ALCcontext *context);
108 static ALeffectslotArray *CreatePtrArray(size_t count) noexcept;
110 /* This can be new'd for the context's default effect slot. */
111 DEF_NEWDEL(ALeffectslot)
114 void UpdateAllEffectSlotProps(ALCcontext *context);
116 #endif