Remove unnecessary atomic members
[openal-soft.git] / OpenAL32 / Include / alSource.h
blob12b4587bce24b1ed60fa9467a196ebd8ea440828
1 #ifndef _AL_SOURCE_H_
2 #define _AL_SOURCE_H_
4 #include "bool.h"
5 #include "alMain.h"
6 #include "alu.h"
7 #include "hrtf.h"
9 #define MAX_SENDS 16
10 #define DEFAULT_SENDS 2
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
16 struct ALbuffer;
17 struct ALsource;
18 struct ALsourceProps;
21 typedef struct ALbufferlistitem {
22 struct ALbuffer *buffer;
23 struct ALbufferlistitem *volatile next;
24 } ALbufferlistitem;
27 struct ALsourceProps {
28 ATOMIC(struct ALsourceProps*) next;
30 ALfloat Pitch;
31 ALfloat Gain;
32 ALfloat OuterGain;
33 ALfloat MinGain;
34 ALfloat MaxGain;
35 ALfloat InnerAngle;
36 ALfloat OuterAngle;
37 ALfloat RefDistance;
38 ALfloat MaxDistance;
39 ALfloat RollOffFactor;
40 ALfloat Position[3];
41 ALfloat Velocity[3];
42 ALfloat Direction[3];
43 ALfloat Orientation[2][3];
44 ALboolean HeadRelative;
45 enum DistanceModel DistanceModel;
46 ALboolean DirectChannels;
48 ALboolean DryGainHFAuto;
49 ALboolean WetGainAuto;
50 ALboolean WetGainHFAuto;
51 ALfloat OuterGainHF;
53 ALfloat AirAbsorptionFactor;
54 ALfloat RoomRolloffFactor;
55 ALfloat DopplerFactor;
57 ALfloat StereoPan[2];
59 ALfloat Radius;
61 /** Direct filter and auxiliary send info. */
62 struct {
63 ALfloat Gain;
64 ALfloat GainHF;
65 ALfloat HFReference;
66 ALfloat GainLF;
67 ALfloat LFReference;
68 } Direct;
69 struct {
70 struct ALeffectslot *Slot;
71 ALfloat Gain;
72 ALfloat GainHF;
73 ALfloat HFReference;
74 ALfloat GainLF;
75 ALfloat LFReference;
76 } Send[];
80 typedef struct ALvoice {
81 struct ALsourceProps *Props;
83 ATOMIC(struct ALsource*) Source;
84 ATOMIC(bool) Playing;
86 /* Current buffer queue item being played. */
87 ATOMIC(ALbufferlistitem*) current_buffer;
89 /**
90 * Source offset in samples, relative to the currently playing buffer, NOT
91 * the whole queue, and the fractional (fixed-point) offset to the next
92 * sample.
94 ATOMIC(ALuint) position;
95 ATOMIC(ALuint) position_fraction;
97 /**
98 * Number of channels and bytes-per-sample for the attached source's
99 * buffer(s).
101 ALsizei NumChannels;
102 ALsizei SampleSize;
104 /** Current target parameters used for mixing. */
105 ALint Step;
107 /* If not 'moving', gain/coefficients are set directly without fading. */
108 ALboolean Moving;
110 ALboolean IsHrtf;
112 ALuint Offset; /* Number of output samples mixed since starting. */
114 alignas(16) ALfloat PrevSamples[MAX_INPUT_CHANNELS][MAX_PRE_SAMPLES];
116 InterpState ResampleState;
118 struct {
119 DirectParams Params[MAX_INPUT_CHANNELS];
121 ALfloat (*Buffer)[BUFFERSIZE];
122 ALsizei Channels;
123 } Direct;
125 struct {
126 SendParams Params[MAX_INPUT_CHANNELS];
128 ALfloat (*Buffer)[BUFFERSIZE];
129 ALsizei Channels;
130 } Send[];
131 } ALvoice;
134 typedef struct ALsource {
135 /** Source properties. */
136 ALfloat Pitch;
137 ALfloat Gain;
138 ALfloat OuterGain;
139 ALfloat MinGain;
140 ALfloat MaxGain;
141 ALfloat InnerAngle;
142 ALfloat OuterAngle;
143 ALfloat RefDistance;
144 ALfloat MaxDistance;
145 ALfloat RollOffFactor;
146 ALfloat Position[3];
147 ALfloat Velocity[3];
148 ALfloat Direction[3];
149 ALfloat Orientation[2][3];
150 ALboolean HeadRelative;
151 enum DistanceModel DistanceModel;
152 ALboolean DirectChannels;
154 ALboolean DryGainHFAuto;
155 ALboolean WetGainAuto;
156 ALboolean WetGainHFAuto;
157 ALfloat OuterGainHF;
159 ALfloat AirAbsorptionFactor;
160 ALfloat RoomRolloffFactor;
161 ALfloat DopplerFactor;
163 /* NOTE: Stereo pan angles are specified in radians, counter-clockwise
164 * rather than clockwise.
166 ALfloat StereoPan[2];
168 ALfloat Radius;
170 /** Direct filter and auxiliary send info. */
171 struct {
172 ALfloat Gain;
173 ALfloat GainHF;
174 ALfloat HFReference;
175 ALfloat GainLF;
176 ALfloat LFReference;
177 } Direct;
178 struct {
179 struct ALeffectslot *Slot;
180 ALfloat Gain;
181 ALfloat GainHF;
182 ALfloat HFReference;
183 ALfloat GainLF;
184 ALfloat LFReference;
185 } *Send;
188 * Last user-specified offset, and the offset type (bytes, samples, or
189 * seconds).
191 ALdouble Offset;
192 ALenum OffsetType;
194 /** Source type (static, streaming, or undetermined) */
195 ALint SourceType;
197 /** Source state (initial, playing, paused, or stopped) */
198 ATOMIC(ALenum) state;
199 ALenum new_state;
201 /** Source Buffer Queue head. */
202 RWLock queue_lock;
203 ATOMIC(ALbufferlistitem*) queue;
205 ATOMIC(ALboolean) looping;
207 ALenum NeedsUpdate;
209 ATOMIC(struct ALsourceProps*) Update;
210 ATOMIC(struct ALsourceProps*) FreeList;
212 /** Self ID */
213 ALuint id;
214 } ALsource;
216 inline void LockSourcesRead(ALCcontext *context)
217 { LockUIntMapRead(&context->SourceMap); }
218 inline void UnlockSourcesRead(ALCcontext *context)
219 { UnlockUIntMapRead(&context->SourceMap); }
220 inline void LockSourcesWrite(ALCcontext *context)
221 { LockUIntMapWrite(&context->SourceMap); }
222 inline void UnlockSourcesWrite(ALCcontext *context)
223 { UnlockUIntMapWrite(&context->SourceMap); }
225 inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
226 { return (struct ALsource*)LookupUIntMapKeyNoLock(&context->SourceMap, id); }
227 inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
228 { return (struct ALsource*)RemoveUIntMapKeyNoLock(&context->SourceMap, id); }
230 void UpdateAllSourceProps(ALCcontext *context);
231 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
232 ALboolean ApplyOffset(ALsource *Source, ALvoice *voice);
235 ALvoid ReleaseALSources(ALCcontext *Context);
237 #ifdef __cplusplus
239 #endif
241 #endif