Combine some dry and wet path types
[openal-soft.git] / OpenAL32 / Include / alSource.h
blobfa73683c3b7f2825f305795a59fc7dee2a098ae9
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 extern enum Resampler DefaultResampler;
16 extern const ALsizei ResamplerPadding[ResamplerMax];
17 extern const ALsizei ResamplerPrePadding[ResamplerMax];
20 typedef struct ALbufferlistitem {
21 struct ALbuffer *buffer;
22 struct ALbufferlistitem *next;
23 struct ALbufferlistitem *prev;
24 } ALbufferlistitem;
27 typedef struct ALactivesource {
28 struct ALsource *Source;
30 /** Method to update mixing parameters. */
31 ALvoid (*Update)(struct ALactivesource *self, const ALCcontext *context);
33 /** Current target parameters used for mixing. */
34 ResamplerFunc Resample;
35 union {
36 MixerFunc Mix;
37 HrtfMixerFunc HrtfMix;
38 } Dry;
39 MixerFunc WetMix;
41 ALboolean IsHrtf;
42 ALint Step;
44 ALuint Offset; /* Number of output samples mixed since starting. */
46 DirectParams Direct;
47 SendParams Send[MAX_SENDS];
48 } ALactivesource;
51 typedef struct ALsource {
52 /** Source properties. */
53 volatile ALfloat Pitch;
54 volatile ALfloat Gain;
55 volatile ALfloat OuterGain;
56 volatile ALfloat MinGain;
57 volatile ALfloat MaxGain;
58 volatile ALfloat InnerAngle;
59 volatile ALfloat OuterAngle;
60 volatile ALfloat RefDistance;
61 volatile ALfloat MaxDistance;
62 volatile ALfloat RollOffFactor;
63 volatile ALfloat Position[3];
64 volatile ALfloat Velocity[3];
65 volatile ALfloat Orientation[3];
66 volatile ALboolean HeadRelative;
67 volatile ALboolean Looping;
68 volatile enum DistanceModel DistanceModel;
69 volatile ALboolean DirectChannels;
71 volatile ALboolean DryGainHFAuto;
72 volatile ALboolean WetGainAuto;
73 volatile ALboolean WetGainHFAuto;
74 volatile ALfloat OuterGainHF;
76 volatile ALfloat AirAbsorptionFactor;
77 volatile ALfloat RoomRolloffFactor;
78 volatile ALfloat DopplerFactor;
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 ALbufferlistitem *volatile queue;
106 ALbufferlistitem *volatile 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 volatile 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