Remove some unnecessary volatile keywords
[openal-soft.git] / OpenAL32 / Include / alAuxEffectSlot.h
blob034ac2179d57869e99017ed50f2bd7a0d46e5865
1 #ifndef _AL_AUXEFFECTSLOT_H_
2 #define _AL_AUXEFFECTSLOT_H_
4 #include "alMain.h"
5 #include "alEffect.h"
7 #include "align.h"
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
13 struct ALeffectStateVtable;
14 struct ALeffectslot;
16 typedef struct ALeffectState {
17 const struct ALeffectStateVtable *vtbl;
19 ALfloat (*OutBuffer)[BUFFERSIZE];
20 ALuint OutChannels;
21 } ALeffectState;
23 void ALeffectState_Destruct(ALeffectState *state);
25 struct ALeffectStateVtable {
26 void (*const Destruct)(ALeffectState *state);
28 ALboolean (*const deviceUpdate)(ALeffectState *state, ALCdevice *device);
29 void (*const update)(ALeffectState *state, const ALCdevice *device, const struct ALeffectslot *slot, const union ALeffectProps *props);
30 void (*const process)(ALeffectState *state, ALuint samplesToDo, const ALfloat (*restrict samplesIn)[BUFFERSIZE], ALfloat (*restrict samplesOut)[BUFFERSIZE], ALuint numChannels);
32 void (*const Delete)(void *ptr);
35 #define DEFINE_ALEFFECTSTATE_VTABLE(T) \
36 DECLARE_THUNK(T, ALeffectState, void, Destruct) \
37 DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \
38 DECLARE_THUNK3(T, ALeffectState, void, update, const ALCdevice*, const ALeffectslot*, const ALeffectProps*) \
39 DECLARE_THUNK4(T, ALeffectState, void, process, ALuint, const ALfloatBUFFERSIZE*restrict, ALfloatBUFFERSIZE*restrict, ALuint) \
40 static void T##_ALeffectState_Delete(void *ptr) \
41 { return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \
43 static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \
44 T##_ALeffectState_Destruct, \
46 T##_ALeffectState_deviceUpdate, \
47 T##_ALeffectState_update, \
48 T##_ALeffectState_process, \
50 T##_ALeffectState_Delete, \
54 struct ALeffectStateFactoryVtable;
56 typedef struct ALeffectStateFactory {
57 const struct ALeffectStateFactoryVtable *vtbl;
58 } ALeffectStateFactory;
60 struct ALeffectStateFactoryVtable {
61 ALeffectState *(*const create)(ALeffectStateFactory *factory);
64 #define DEFINE_ALEFFECTSTATEFACTORY_VTABLE(T) \
65 DECLARE_THUNK(T, ALeffectStateFactory, ALeffectState*, create) \
67 static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable = { \
68 T##_ALeffectStateFactory_create, \
72 #define MAX_EFFECT_CHANNELS (4)
75 struct ALeffectslotProps {
76 ATOMIC(ALfloat) Gain;
77 ATOMIC(ALboolean) AuxSendAuto;
79 ATOMIC(ALenum) Type;
80 ALeffectProps Props;
82 ATOMIC(ALeffectState*) State;
84 ATOMIC(struct ALeffectslotProps*) next;
88 typedef struct ALeffectslot {
89 ALfloat Gain;
90 ALboolean AuxSendAuto;
92 struct {
93 ALenum Type;
94 ALeffectProps Props;
96 ALeffectState *State;
97 } Effect;
99 RefCount ref;
101 ATOMIC(struct ALeffectslotProps*) Update;
102 ATOMIC(struct ALeffectslotProps*) FreeList;
104 struct {
105 ALfloat Gain;
106 ALboolean AuxSendAuto;
108 ALenum EffectType;
109 ALeffectState *EffectState;
111 ALfloat RoomRolloff; /* Added to the source's room rolloff, not multiplied. */
112 ALfloat DecayTime;
113 ALfloat AirAbsorptionGainHF;
114 } Params;
116 /* Self ID */
117 ALuint id;
119 ALuint NumChannels;
120 BFChannelConfig ChanMap[MAX_EFFECT_CHANNELS];
121 /* Wet buffer configuration is ACN channel order with N3D scaling:
122 * * Channel 0 is the unattenuated mono signal.
123 * * Channel 1 is OpenAL -X
124 * * Channel 2 is OpenAL Y
125 * * Channel 3 is OpenAL -Z
126 * Consequently, effects that only want to work with mono input can use
127 * channel 0 by itself. Effects that want multichannel can process the
128 * ambisonics signal and make a B-Format pan (ComputeFirstOrderGains) for
129 * first-order device output (FOAOut).
131 alignas(16) ALfloat WetBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE];
133 ATOMIC(struct ALeffectslot*) next;
134 } ALeffectslot;
136 inline void LockEffectSlotsRead(ALCcontext *context)
137 { LockUIntMapRead(&context->EffectSlotMap); }
138 inline void UnlockEffectSlotsRead(ALCcontext *context)
139 { UnlockUIntMapRead(&context->EffectSlotMap); }
140 inline void LockEffectSlotsWrite(ALCcontext *context)
141 { LockUIntMapWrite(&context->EffectSlotMap); }
142 inline void UnlockEffectSlotsWrite(ALCcontext *context)
143 { UnlockUIntMapWrite(&context->EffectSlotMap); }
145 inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id)
146 { return (struct ALeffectslot*)LookupUIntMapKeyNoLock(&context->EffectSlotMap, id); }
147 inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id)
148 { return (struct ALeffectslot*)RemoveUIntMapKeyNoLock(&context->EffectSlotMap, id); }
150 ALenum InitEffectSlot(ALeffectslot *slot);
151 void DeinitEffectSlot(ALeffectslot *slot);
152 void UpdateEffectSlotProps(ALeffectslot *slot);
153 ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
156 ALeffectStateFactory *ALnullStateFactory_getFactory(void);
157 ALeffectStateFactory *ALreverbStateFactory_getFactory(void);
158 ALeffectStateFactory *ALautowahStateFactory_getFactory(void);
159 ALeffectStateFactory *ALchorusStateFactory_getFactory(void);
160 ALeffectStateFactory *ALcompressorStateFactory_getFactory(void);
161 ALeffectStateFactory *ALdistortionStateFactory_getFactory(void);
162 ALeffectStateFactory *ALechoStateFactory_getFactory(void);
163 ALeffectStateFactory *ALequalizerStateFactory_getFactory(void);
164 ALeffectStateFactory *ALflangerStateFactory_getFactory(void);
165 ALeffectStateFactory *ALmodulatorStateFactory_getFactory(void);
167 ALeffectStateFactory *ALdedicatedStateFactory_getFactory(void);
170 ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect);
172 void InitEffectFactoryMap(void);
173 void DeinitEffectFactoryMap(void);
175 #ifdef __cplusplus
177 #endif
179 #endif