5 #define DEFAULT_SENDS 2
20 typedef struct ALbufferlistitem
{
21 struct ALbuffer
*buffer
;
22 struct ALbufferlistitem
*volatile next
;
26 struct ALsourceProps
{
27 ATOMIC(struct ALsourceProps
*) next
;
29 ATOMIC(ALfloat
) Pitch
;
31 ATOMIC(ALfloat
) OuterGain
;
32 ATOMIC(ALfloat
) MinGain
;
33 ATOMIC(ALfloat
) MaxGain
;
34 ATOMIC(ALfloat
) InnerAngle
;
35 ATOMIC(ALfloat
) OuterAngle
;
36 ATOMIC(ALfloat
) RefDistance
;
37 ATOMIC(ALfloat
) MaxDistance
;
38 ATOMIC(ALfloat
) RollOffFactor
;
39 ATOMIC(ALfloat
) Position
[3];
40 ATOMIC(ALfloat
) Velocity
[3];
41 ATOMIC(ALfloat
) Direction
[3];
42 ATOMIC(ALfloat
) Orientation
[2][3];
43 ATOMIC(ALboolean
) HeadRelative
;
44 ATOMIC(enum DistanceModel
) DistanceModel
;
45 ATOMIC(ALboolean
) DirectChannels
;
47 ATOMIC(ALboolean
) DryGainHFAuto
;
48 ATOMIC(ALboolean
) WetGainAuto
;
49 ATOMIC(ALboolean
) WetGainHFAuto
;
50 ATOMIC(ALfloat
) OuterGainHF
;
52 ATOMIC(ALfloat
) AirAbsorptionFactor
;
53 ATOMIC(ALfloat
) RoomRolloffFactor
;
54 ATOMIC(ALfloat
) DopplerFactor
;
56 ATOMIC(ALfloat
) StereoPan
[2];
58 ATOMIC(ALfloat
) Radius
;
60 /** Direct filter and auxiliary send info. */
63 ATOMIC(ALfloat
) GainHF
;
64 ATOMIC(ALfloat
) HFReference
;
65 ATOMIC(ALfloat
) GainLF
;
66 ATOMIC(ALfloat
) LFReference
;
69 ATOMIC(struct ALeffectslot
*) Slot
;
71 ATOMIC(ALfloat
) GainHF
;
72 ATOMIC(ALfloat
) HFReference
;
73 ATOMIC(ALfloat
) GainLF
;
74 ATOMIC(ALfloat
) LFReference
;
79 typedef struct ALvoice
{
80 struct ALsourceProps
*Props
;
82 struct ALsource
*Source
;
84 /** Current target parameters used for mixing. */
87 /* If not 'moving', gain/coefficients are set directly without fading. */
92 ALuint Offset
; /* Number of output samples mixed since starting. */
94 alignas(16) ALfloat PrevSamples
[MAX_INPUT_CHANNELS
][MAX_PRE_SAMPLES
];
96 InterpState ResampleState
;
99 DirectParams Params
[MAX_INPUT_CHANNELS
];
101 ALfloat (*Buffer
)[BUFFERSIZE
];
106 SendParams Params
[MAX_INPUT_CHANNELS
];
108 ALfloat (*Buffer
)[BUFFERSIZE
];
114 typedef struct ALsource
{
115 /** Source properties. */
125 ALfloat RollOffFactor
;
128 ALfloat Direction
[3];
129 ALfloat Orientation
[2][3];
130 ALboolean HeadRelative
;
131 enum DistanceModel DistanceModel
;
132 ALboolean DirectChannels
;
134 ALboolean DryGainHFAuto
;
135 ALboolean WetGainAuto
;
136 ALboolean WetGainHFAuto
;
139 ALfloat AirAbsorptionFactor
;
140 ALfloat RoomRolloffFactor
;
141 ALfloat DopplerFactor
;
143 /* NOTE: Stereo pan angles are specified in radians, counter-clockwise
144 * rather than clockwise.
146 ALfloat StereoPan
[2];
150 /** Direct filter and auxiliary send info. */
159 struct ALeffectslot
*Slot
;
168 * Last user-specified offset, and the offset type (bytes, samples, or
174 /** Source type (static, streaming, or undetermined) */
177 /** Source state (initial, playing, paused, or stopped) */
178 ATOMIC(ALenum
) state
;
181 /** Source Buffer Queue info. */
183 ATOMIC(ALbufferlistitem
*) queue
;
184 ATOMIC(ALbufferlistitem
*) current_buffer
;
187 * Source offset in samples, relative to the currently playing buffer, NOT
188 * the whole queue, and the fractional (fixed-point) offset to the next
191 ATOMIC(ALuint
) position
;
192 ATOMIC(ALuint
) position_fraction
;
194 ATOMIC(ALboolean
) looping
;
196 /** Current buffer sample info. */
202 ATOMIC(struct ALsourceProps
*) Update
;
203 ATOMIC(struct ALsourceProps
*) FreeList
;
209 inline void LockSourcesRead(ALCcontext
*context
)
210 { LockUIntMapRead(&context
->SourceMap
); }
211 inline void UnlockSourcesRead(ALCcontext
*context
)
212 { UnlockUIntMapRead(&context
->SourceMap
); }
213 inline void LockSourcesWrite(ALCcontext
*context
)
214 { LockUIntMapWrite(&context
->SourceMap
); }
215 inline void UnlockSourcesWrite(ALCcontext
*context
)
216 { UnlockUIntMapWrite(&context
->SourceMap
); }
218 inline struct ALsource
*LookupSource(ALCcontext
*context
, ALuint id
)
219 { return (struct ALsource
*)LookupUIntMapKeyNoLock(&context
->SourceMap
, id
); }
220 inline struct ALsource
*RemoveSource(ALCcontext
*context
, ALuint id
)
221 { return (struct ALsource
*)RemoveUIntMapKeyNoLock(&context
->SourceMap
, id
); }
223 void UpdateAllSourceProps(ALCcontext
*context
);
224 ALvoid
SetSourceState(ALsource
*Source
, ALCcontext
*Context
, ALenum state
);
225 ALboolean
ApplyOffset(ALsource
*Source
);
227 inline ALboolean
IsPlayingOrPaused(const ALsource
*source
)
229 ALenum state
= ATOMIC_LOAD(&source
->state
, almemory_order_relaxed
);
230 return state
== AL_PLAYING
|| state
== AL_PAUSED
;
234 ALvoid
ReleaseALSources(ALCcontext
*Context
);