Get the mixer and resampler functions when needed
[openal-soft.git] / OpenAL32 / Include / alSource.h
blob6c6485ae17c3603c42bbe5d040d0849827449cd5
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 ALint Step;
36 ALboolean IsHrtf;
38 ALuint Offset; /* Number of output samples mixed since starting. */
40 DirectParams Direct;
41 SendParams Send[MAX_SENDS];
42 } ALactivesource;
45 typedef struct ALsource {
46 /** Source properties. */
47 volatile ALfloat Pitch;
48 volatile ALfloat Gain;
49 volatile ALfloat OuterGain;
50 volatile ALfloat MinGain;
51 volatile ALfloat MaxGain;
52 volatile ALfloat InnerAngle;
53 volatile ALfloat OuterAngle;
54 volatile ALfloat RefDistance;
55 volatile ALfloat MaxDistance;
56 volatile ALfloat RollOffFactor;
57 volatile ALfloat Position[3];
58 volatile ALfloat Velocity[3];
59 volatile ALfloat Orientation[3];
60 volatile ALboolean HeadRelative;
61 volatile ALboolean Looping;
62 volatile enum DistanceModel DistanceModel;
63 volatile ALboolean DirectChannels;
65 volatile ALboolean DryGainHFAuto;
66 volatile ALboolean WetGainAuto;
67 volatile ALboolean WetGainHFAuto;
68 volatile ALfloat OuterGainHF;
70 volatile ALfloat AirAbsorptionFactor;
71 volatile ALfloat RoomRolloffFactor;
72 volatile ALfloat DopplerFactor;
74 enum Resampler Resampler;
76 /**
77 * Last user-specified offset, and the offset type (bytes, samples, or
78 * seconds).
80 ALdouble Offset;
81 ALenum OffsetType;
83 /** Source type (static, streaming, or undetermined) */
84 volatile ALint SourceType;
86 /** Source state (initial, playing, paused, or stopped) */
87 volatile ALenum state;
88 ALenum new_state;
90 /**
91 * Source offset in samples, relative to the currently playing buffer, NOT
92 * the whole queue, and the fractional (fixed-point) offset to the next
93 * sample.
95 ALuint position;
96 ALuint position_fraction;
98 /** Source Buffer Queue info. */
99 ALbufferlistitem *volatile queue;
100 ALbufferlistitem *volatile current_buffer;
101 RWLock queue_lock;
103 /** Current buffer sample info. */
104 ALuint NumChannels;
105 ALuint SampleSize;
107 /** Direct filter and auxiliary send info. */
108 struct {
109 ALfloat Gain;
110 ALfloat GainHF;
111 ALfloat HFReference;
112 ALfloat GainLF;
113 ALfloat LFReference;
114 } Direct;
115 struct {
116 struct ALeffectslot *Slot;
117 ALfloat Gain;
118 ALfloat GainHF;
119 ALfloat HFReference;
120 ALfloat GainLF;
121 ALfloat LFReference;
122 } Send[MAX_SENDS];
124 /** Source needs to update its mixing parameters. */
125 volatile ALenum NeedsUpdate;
127 /** Self ID */
128 ALuint id;
129 } ALsource;
131 inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
132 { return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
133 inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
134 { return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
136 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
137 ALboolean ApplyOffset(ALsource *Source);
139 ALvoid ReleaseALSources(ALCcontext *Context);
141 #ifdef __cplusplus
143 #endif
145 #endif