Rename activesource to voice
[openal-soft.git] / OpenAL32 / Include / alSource.h
blob39bb8185237e36c65d1ee618342672989ff0793b
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 volatile ALfloat Position[3];
61 volatile ALfloat Velocity[3];
62 volatile ALfloat Orientation[3];
63 volatile ALboolean HeadRelative;
64 volatile ALboolean Looping;
65 volatile enum DistanceModel DistanceModel;
66 volatile ALboolean DirectChannels;
68 volatile ALboolean DryGainHFAuto;
69 volatile ALboolean WetGainAuto;
70 volatile ALboolean WetGainHFAuto;
71 volatile ALfloat OuterGainHF;
73 volatile ALfloat AirAbsorptionFactor;
74 volatile ALfloat RoomRolloffFactor;
75 volatile ALfloat DopplerFactor;
77 volatile ALfloat Radius;
79 enum Resampler Resampler;
81 /**
82 * Last user-specified offset, and the offset type (bytes, samples, or
83 * seconds).
85 ALdouble Offset;
86 ALenum OffsetType;
88 /** Source type (static, streaming, or undetermined) */
89 volatile ALint SourceType;
91 /** Source state (initial, playing, paused, or stopped) */
92 volatile ALenum state;
93 ALenum new_state;
95 /**
96 * Source offset in samples, relative to the currently playing buffer, NOT
97 * the whole queue, and the fractional (fixed-point) offset to the next
98 * sample.
100 ALuint position;
101 ALuint position_fraction;
103 /** Source Buffer Queue info. */
104 ATOMIC(ALbufferlistitem*) queue;
105 ATOMIC(ALbufferlistitem*) current_buffer;
106 RWLock queue_lock;
108 /** Current buffer sample info. */
109 ALuint NumChannels;
110 ALuint SampleSize;
112 /** Direct filter and auxiliary send info. */
113 struct {
114 ALfloat Gain;
115 ALfloat GainHF;
116 ALfloat HFReference;
117 ALfloat GainLF;
118 ALfloat LFReference;
119 } Direct;
120 struct {
121 struct ALeffectslot *Slot;
122 ALfloat Gain;
123 ALfloat GainHF;
124 ALfloat HFReference;
125 ALfloat GainLF;
126 ALfloat LFReference;
127 } Send[MAX_SENDS];
129 /** Source needs to update its mixing parameters. */
130 ATOMIC(ALenum) NeedsUpdate;
132 /** Self ID */
133 ALuint id;
134 } ALsource;
136 inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
137 { return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
138 inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
139 { return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
141 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
142 ALboolean ApplyOffset(ALsource *Source);
144 ALvoid ReleaseALSources(ALCcontext *Context);
146 #ifdef __cplusplus
148 #endif
150 #endif