Use aluVector in some more places
[openal-soft.git] / OpenAL32 / Include / alSource.h
blobfe2867b14d52f07d42dee55b556671a413f3da4b
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 "hrtf.h"
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
14 struct ALbuffer;
15 struct ALsource;
17 extern enum Resampler DefaultResampler;
19 extern const ALsizei ResamplerPadding[ResamplerMax];
20 extern const ALsizei ResamplerPrePadding[ResamplerMax];
23 typedef struct ALbufferlistitem {
24 struct ALbuffer *buffer;
25 struct ALbufferlistitem *volatile next;
26 struct ALbufferlistitem *volatile prev;
27 } ALbufferlistitem;
30 typedef struct ALvoice {
31 struct ALsource *volatile Source;
33 /** Method to update mixing parameters. */
34 ALvoid (*Update)(struct ALvoice *self, const struct ALsource *source, const ALCcontext *context);
36 /** Current target parameters used for mixing. */
37 ALint Step;
39 ALboolean IsHrtf;
41 ALuint Offset; /* Number of output samples mixed since starting. */
43 DirectParams Direct;
44 SendParams Send[MAX_SENDS];
45 } ALvoice;
48 typedef struct ALsource {
49 /** Source properties. */
50 volatile ALfloat Pitch;
51 volatile ALfloat Gain;
52 volatile ALfloat OuterGain;
53 volatile ALfloat MinGain;
54 volatile ALfloat MaxGain;
55 volatile ALfloat InnerAngle;
56 volatile ALfloat OuterAngle;
57 volatile ALfloat RefDistance;
58 volatile ALfloat MaxDistance;
59 volatile ALfloat RollOffFactor;
60 aluVector Position;
61 aluVector Velocity;
62 aluVector Direction;
63 volatile ALfloat Orientation[2][3];
64 volatile ALboolean HeadRelative;
65 volatile ALboolean Looping;
66 volatile enum DistanceModel DistanceModel;
67 volatile ALboolean DirectChannels;
69 volatile ALboolean DryGainHFAuto;
70 volatile ALboolean WetGainAuto;
71 volatile ALboolean WetGainHFAuto;
72 volatile ALfloat OuterGainHF;
74 volatile ALfloat AirAbsorptionFactor;
75 volatile ALfloat RoomRolloffFactor;
76 volatile ALfloat DopplerFactor;
78 volatile ALfloat Radius;
80 enum Resampler Resampler;
82 /**
83 * Last user-specified offset, and the offset type (bytes, samples, or
84 * seconds).
86 ALdouble Offset;
87 ALenum OffsetType;
89 /** Source type (static, streaming, or undetermined) */
90 volatile ALint SourceType;
92 /** Source state (initial, playing, paused, or stopped) */
93 volatile ALenum state;
94 ALenum new_state;
96 /**
97 * Source offset in samples, relative to the currently playing buffer, NOT
98 * the whole queue, and the fractional (fixed-point) offset to the next
99 * sample.
101 ALuint position;
102 ALuint position_fraction;
104 /** Source Buffer Queue info. */
105 ATOMIC(ALbufferlistitem*) queue;
106 ATOMIC(ALbufferlistitem*) current_buffer;
107 RWLock queue_lock;
109 /** Current buffer sample info. */
110 ALuint NumChannels;
111 ALuint SampleSize;
113 /** Direct filter and auxiliary send info. */
114 struct {
115 ALfloat Gain;
116 ALfloat GainHF;
117 ALfloat HFReference;
118 ALfloat GainLF;
119 ALfloat LFReference;
120 } Direct;
121 struct {
122 struct ALeffectslot *Slot;
123 ALfloat Gain;
124 ALfloat GainHF;
125 ALfloat HFReference;
126 ALfloat GainLF;
127 ALfloat LFReference;
128 } Send[MAX_SENDS];
130 /** Source needs to update its mixing parameters. */
131 ATOMIC(ALenum) NeedsUpdate;
133 /** Self ID */
134 ALuint id;
135 } ALsource;
137 inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
138 { return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
139 inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
140 { return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
142 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
143 ALboolean ApplyOffset(ALsource *Source);
145 ALvoid ReleaseALSources(ALCcontext *Context);
147 #ifdef __cplusplus
149 #endif
151 #endif