Add macros for generic atomic functionality
[openal-soft.git] / OpenAL32 / Include / alSource.h
blob4b2ffe0b796b82ecc3960cd37e90635830e24658
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 volatile ALfloat Radius;
76 enum Resampler Resampler;
78 /**
79 * Last user-specified offset, and the offset type (bytes, samples, or
80 * seconds).
82 ALdouble Offset;
83 ALenum OffsetType;
85 /** Source type (static, streaming, or undetermined) */
86 volatile ALint SourceType;
88 /** Source state (initial, playing, paused, or stopped) */
89 volatile ALenum state;
90 ALenum new_state;
92 /**
93 * Source offset in samples, relative to the currently playing buffer, NOT
94 * the whole queue, and the fractional (fixed-point) offset to the next
95 * sample.
97 ALuint position;
98 ALuint position_fraction;
100 /** Source Buffer Queue info. */
101 ALbufferlistitem *volatile queue;
102 ALbufferlistitem *volatile current_buffer;
103 RWLock queue_lock;
105 /** Current buffer sample info. */
106 ALuint NumChannels;
107 ALuint SampleSize;
109 /** Direct filter and auxiliary send info. */
110 struct {
111 ALfloat Gain;
112 ALfloat GainHF;
113 ALfloat HFReference;
114 ALfloat GainLF;
115 ALfloat LFReference;
116 } Direct;
117 struct {
118 struct ALeffectslot *Slot;
119 ALfloat Gain;
120 ALfloat GainHF;
121 ALfloat HFReference;
122 ALfloat GainLF;
123 ALfloat LFReference;
124 } Send[MAX_SENDS];
126 /** Source needs to update its mixing parameters. */
127 ATOMIC(ALenum) NeedsUpdate;
129 /** Self ID */
130 ALuint id;
131 } ALsource;
133 inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
134 { return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
135 inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
136 { return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
138 ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
139 ALboolean ApplyOffset(ALsource *Source);
141 ALvoid ReleaseALSources(ALCcontext *Context);
143 #ifdef __cplusplus
145 #endif
147 #endif