Pass the offset latency properties to the set handler
[openal-soft.git] / OpenAL32 / Include / alSource.h
blobd8ffc9aa8fbf21cb23b31a8351120fe2940c3ec0
1 #ifndef _AL_SOURCE_H_
2 #define _AL_SOURCE_H_
4 #define MAX_SENDS 4
6 #include "alMain.h"
7 #include "alu.h"
8 #include "alFilter.h"
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
14 #define SRC_HISTORY_BITS (6)
15 #define SRC_HISTORY_LENGTH (1<<SRC_HISTORY_BITS)
16 #define SRC_HISTORY_MASK (SRC_HISTORY_LENGTH-1)
18 extern enum Resampler DefaultResampler;
20 extern const ALsizei ResamplerPadding[ResamplerMax];
21 extern const ALsizei ResamplerPrePadding[ResamplerMax];
24 typedef struct ALbufferlistitem
26 struct ALbuffer *buffer;
27 struct ALbufferlistitem *next;
28 struct ALbufferlistitem *prev;
29 } ALbufferlistitem;
31 typedef struct HrtfState {
32 ALboolean Moving;
33 ALuint Counter;
34 ALIGN(16) ALfloat History[MaxChannels][SRC_HISTORY_LENGTH];
35 ALIGN(16) ALfloat Values[MaxChannels][HRIR_LENGTH][2];
36 ALuint Offset;
37 } HrtfState;
39 typedef struct HrtfParams {
40 ALfloat Gain;
41 ALfloat Dir[3];
42 ALIGN(16) ALfloat Coeffs[MaxChannels][HRIR_LENGTH][2];
43 ALIGN(16) ALfloat CoeffStep[HRIR_LENGTH][2];
44 ALuint Delay[MaxChannels][2];
45 ALint DelayStep[2];
46 ALuint IrSize;
47 } HrtfParams;
49 typedef struct DirectParams {
50 ALfloat (*OutBuffer)[BUFFERSIZE];
51 ALfloat *ClickRemoval;
52 ALfloat *PendingClicks;
54 struct {
55 HrtfParams Params;
56 HrtfState *State;
57 } Hrtf;
59 /* A mixing matrix. First subscript is the channel number of the input data
60 * (regardless of channel configuration) and the second is the channel
61 * target (eg. FrontLeft). Not used with HRTF. */
62 ALfloat Gains[MaxChannels][MaxChannels];
64 /* A low-pass filter, using 2 chained one-pole filters. */
65 FILTER iirFilter;
66 ALfloat history[MaxChannels*2];
67 } DirectParams;
69 typedef struct SendParams {
70 struct ALeffectslot *Slot;
72 /* Gain control, which applies to all input channels to a single (mono)
73 * output buffer. */
74 ALfloat Gain;
76 /* A low-pass filter, using 2 chained one-pole filters. */
77 FILTER iirFilter;
78 ALfloat history[MaxChannels*2];
79 } SendParams;
82 typedef struct ALsource
84 /** Source properties. */
85 volatile ALfloat Pitch;
86 volatile ALfloat Gain;
87 volatile ALfloat OuterGain;
88 volatile ALfloat MinGain;
89 volatile ALfloat MaxGain;
90 volatile ALfloat InnerAngle;
91 volatile ALfloat OuterAngle;
92 volatile ALfloat RefDistance;
93 volatile ALfloat MaxDistance;
94 volatile ALfloat RollOffFactor;
95 volatile ALfloat Position[3];
96 volatile ALfloat Velocity[3];
97 volatile ALfloat Orientation[3];
98 volatile ALboolean HeadRelative;
99 volatile ALboolean Looping;
100 volatile enum DistanceModel DistanceModel;
101 volatile ALboolean DirectChannels;
103 volatile ALboolean DryGainHFAuto;
104 volatile ALboolean WetGainAuto;
105 volatile ALboolean WetGainHFAuto;
106 volatile ALfloat OuterGainHF;
108 volatile ALfloat AirAbsorptionFactor;
109 volatile ALfloat RoomRolloffFactor;
110 volatile ALfloat DopplerFactor;
112 enum Resampler Resampler;
115 * Last user-specified offset, and the offset type (bytes, samples, or
116 * seconds).
118 ALdouble Offset;
119 ALenum OffsetType;
121 /** Source type (static, streaming, or undetermined) */
122 volatile ALint SourceType;
124 /** Source state (initial, playing, paused, or stopped) */
125 volatile ALenum state;
126 ALenum new_state;
129 * Source offset in samples, relative to the currently playing buffer, NOT
130 * the whole queue, and the fractional (fixed-point) offset to the next
131 * sample.
133 ALuint position;
134 ALuint position_fraction;
136 /** Source Buffer Queue info. */
137 ALbufferlistitem *queue;
138 ALuint BuffersInQueue;
139 ALuint BuffersPlayed;
141 /** Current buffer sample info. */
142 ALuint NumChannels;
143 ALuint SampleSize;
145 /** Direct filter and auxiliary send info. */
146 ALfloat DirectGain;
147 ALfloat DirectGainHF;
149 struct {
150 struct ALeffectslot *Slot;
151 ALfloat Gain;
152 ALfloat GainHF;
153 } Send[MAX_SENDS];
155 /** HRTF info. */
156 HrtfState Hrtf;
158 /** Current target parameters used for mixing. */
159 struct {
160 ResamplerFunc Resample;
161 DryMixerFunc DryMix;
162 WetMixerFunc WetMix;
164 ALint Step;
166 DirectParams Direct;
168 SendParams Send[MAX_SENDS];
169 } Params;
170 /** Source needs to update its mixing parameters. */
171 volatile ALenum NeedsUpdate;
173 /** Method to update mixing parameters. */
174 ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
176 /** Self ID */
177 ALuint id;
178 } ALsource;
179 #define ALsource_Update(s,a) ((s)->Update(s,a))
181 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
182 ALboolean ApplyOffset(ALsource *Source);
184 ALvoid ReleaseALSources(ALCcontext *Context);
186 #ifdef __cplusplus
188 #endif
190 #endif