19 typedef struct ALbufferlistitem
{
20 struct ALbuffer
*buffer
;
21 struct ALbufferlistitem
*volatile next
;
25 struct ALsourceProps
{
26 ATOMIC(struct ALsourceProps
*) next
;
28 ATOMIC(ALfloat
) Pitch
;
30 ATOMIC(ALfloat
) OuterGain
;
31 ATOMIC(ALfloat
) MinGain
;
32 ATOMIC(ALfloat
) MaxGain
;
33 ATOMIC(ALfloat
) InnerAngle
;
34 ATOMIC(ALfloat
) OuterAngle
;
35 ATOMIC(ALfloat
) RefDistance
;
36 ATOMIC(ALfloat
) MaxDistance
;
37 ATOMIC(ALfloat
) RollOffFactor
;
38 ATOMIC(ALfloat
) Position
[3];
39 ATOMIC(ALfloat
) Velocity
[3];
40 ATOMIC(ALfloat
) Direction
[3];
41 ATOMIC(ALfloat
) Orientation
[2][3];
42 ATOMIC(ALboolean
) HeadRelative
;
43 ATOMIC(enum DistanceModel
) DistanceModel
;
44 ATOMIC(ALboolean
) DirectChannels
;
46 ATOMIC(ALboolean
) DryGainHFAuto
;
47 ATOMIC(ALboolean
) WetGainAuto
;
48 ATOMIC(ALboolean
) WetGainHFAuto
;
49 ATOMIC(ALfloat
) OuterGainHF
;
51 ATOMIC(ALfloat
) AirAbsorptionFactor
;
52 ATOMIC(ALfloat
) RoomRolloffFactor
;
53 ATOMIC(ALfloat
) DopplerFactor
;
55 ATOMIC(ALfloat
) StereoPan
[2];
57 ATOMIC(ALfloat
) Radius
;
59 /** Direct filter and auxiliary send info. */
62 ATOMIC(ALfloat
) GainHF
;
63 ATOMIC(ALfloat
) HFReference
;
64 ATOMIC(ALfloat
) GainLF
;
65 ATOMIC(ALfloat
) LFReference
;
68 ATOMIC(struct ALeffectslot
*) Slot
;
70 ATOMIC(ALfloat
) GainHF
;
71 ATOMIC(ALfloat
) HFReference
;
72 ATOMIC(ALfloat
) GainLF
;
73 ATOMIC(ALfloat
) LFReference
;
78 typedef struct ALvoice
{
79 struct ALsourceProps
*Props
;
81 struct ALsource
*Source
;
83 /** Current target parameters used for mixing. */
86 /* If not 'moving', gain/coefficients are set directly without fading. */
91 ALuint Offset
; /* Number of output samples mixed since starting. */
93 alignas(16) ALfloat PrevSamples
[MAX_INPUT_CHANNELS
][MAX_PRE_SAMPLES
];
95 InterpState ResampleState
;
98 DirectParams Params
[MAX_INPUT_CHANNELS
];
100 ALfloat (*Buffer
)[BUFFERSIZE
];
105 SendParams Params
[MAX_INPUT_CHANNELS
];
107 ALfloat (*Buffer
)[BUFFERSIZE
];
113 typedef struct ALsource
{
114 /** Source properties. */
124 ALfloat RollOffFactor
;
127 ALfloat Direction
[3];
128 ALfloat Orientation
[2][3];
129 ALboolean HeadRelative
;
130 enum DistanceModel DistanceModel
;
131 ALboolean DirectChannels
;
133 ALboolean DryGainHFAuto
;
134 ALboolean WetGainAuto
;
135 ALboolean WetGainHFAuto
;
138 ALfloat AirAbsorptionFactor
;
139 ALfloat RoomRolloffFactor
;
140 ALfloat DopplerFactor
;
142 /* NOTE: Stereo pan angles are specified in radians, counter-clockwise
143 * rather than clockwise.
145 ALfloat StereoPan
[2];
149 /** Direct filter and auxiliary send info. */
158 struct ALeffectslot
*Slot
;
167 * Last user-specified offset, and the offset type (bytes, samples, or
173 /** Source type (static, streaming, or undetermined) */
176 /** Source state (initial, playing, paused, or stopped) */
177 ATOMIC(ALenum
) state
;
180 /** Source Buffer Queue info. */
182 ATOMIC(ALbufferlistitem
*) queue
;
183 ATOMIC(ALbufferlistitem
*) current_buffer
;
186 * Source offset in samples, relative to the currently playing buffer, NOT
187 * the whole queue, and the fractional (fixed-point) offset to the next
190 ATOMIC(ALuint
) position
;
191 ATOMIC(ALuint
) position_fraction
;
193 ATOMIC(ALboolean
) looping
;
195 /** Current buffer sample info. */
201 ATOMIC(struct ALsourceProps
*) Update
;
202 ATOMIC(struct ALsourceProps
*) FreeList
;
208 inline void LockSourcesRead(ALCcontext
*context
)
209 { LockUIntMapRead(&context
->SourceMap
); }
210 inline void UnlockSourcesRead(ALCcontext
*context
)
211 { UnlockUIntMapRead(&context
->SourceMap
); }
212 inline void LockSourcesWrite(ALCcontext
*context
)
213 { LockUIntMapWrite(&context
->SourceMap
); }
214 inline void UnlockSourcesWrite(ALCcontext
*context
)
215 { UnlockUIntMapWrite(&context
->SourceMap
); }
217 inline struct ALsource
*LookupSource(ALCcontext
*context
, ALuint id
)
218 { return (struct ALsource
*)LookupUIntMapKeyNoLock(&context
->SourceMap
, id
); }
219 inline struct ALsource
*RemoveSource(ALCcontext
*context
, ALuint id
)
220 { return (struct ALsource
*)RemoveUIntMapKeyNoLock(&context
->SourceMap
, id
); }
222 void UpdateAllSourceProps(ALCcontext
*context
);
223 ALvoid
SetSourceState(ALsource
*Source
, ALCcontext
*Context
, ALenum state
);
224 ALboolean
ApplyOffset(ALsource
*Source
);
226 inline ALboolean
IsPlayingOrPaused(const ALsource
*source
)
228 ALenum state
= ATOMIC_LOAD_SEQ(&source
->state
);
229 return state
== AL_PLAYING
|| state
== AL_PAUSED
;
233 ALvoid
ReleaseALSources(ALCcontext
*Context
);