Combine the direct and send mixers
[openal-soft.git] / OpenAL32 / Include / alSource.h
blobf75a670b27f9456c3215114f8e8b9167a8705c1a
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 MixerFunc Mix;
36 HrtfMixerFunc HrtfMix;
38 ALboolean IsHrtf;
39 ALint Step;
41 ALuint Offset; /* Number of output samples mixed since starting. */
43 DirectParams Direct;
44 SendParams Send[MAX_SENDS];
45 } ALactivesource;
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 enum Resampler Resampler;
79 /**
80 * Last user-specified offset, and the offset type (bytes, samples, or
81 * seconds).
83 ALdouble Offset;
84 ALenum OffsetType;
86 /** Source type (static, streaming, or undetermined) */
87 volatile ALint SourceType;
89 /** Source state (initial, playing, paused, or stopped) */
90 volatile ALenum state;
91 ALenum new_state;
93 /**
94 * Source offset in samples, relative to the currently playing buffer, NOT
95 * the whole queue, and the fractional (fixed-point) offset to the next
96 * sample.
98 ALuint position;
99 ALuint position_fraction;
101 /** Source Buffer Queue info. */
102 ALbufferlistitem *volatile queue;
103 ALbufferlistitem *volatile current_buffer;
104 RWLock queue_lock;
106 /** Current buffer sample info. */
107 ALuint NumChannels;
108 ALuint SampleSize;
110 /** Direct filter and auxiliary send info. */
111 struct {
112 ALfloat Gain;
113 ALfloat GainHF;
114 ALfloat HFReference;
115 ALfloat GainLF;
116 ALfloat LFReference;
117 } Direct;
118 struct {
119 struct ALeffectslot *Slot;
120 ALfloat Gain;
121 ALfloat GainHF;
122 ALfloat HFReference;
123 ALfloat GainLF;
124 ALfloat LFReference;
125 } Send[MAX_SENDS];
127 /** Source needs to update its mixing parameters. */
128 volatile ALenum NeedsUpdate;
130 /** Self ID */
131 ALuint id;
132 } ALsource;
134 inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
135 { return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
136 inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
137 { return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
139 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
140 ALboolean ApplyOffset(ALsource *Source);
142 ALvoid ReleaseALSources(ALCcontext *Context);
144 #ifdef __cplusplus
146 #endif
148 #endif