Atuomatically clean up sources with its sublist's destruction
[openal-soft.git] / OpenAL32 / Include / alSource.h
blob05ccdadf410127aa3babcfb8cfe5ffcab2494c27
1 #ifndef _AL_SOURCE_H_
2 #define _AL_SOURCE_H_
4 #include "alMain.h"
5 #include "alu.h"
6 #include "hrtf.h"
7 #include "almalloc.h"
8 #include "atomic.h"
10 #define MAX_SENDS 16
11 #define DEFAULT_SENDS 2
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
17 struct ALbuffer;
18 struct ALsource;
21 typedef struct ALbufferlistitem {
22 ATOMIC(struct ALbufferlistitem*) next;
23 ALsizei max_samples;
24 ALsizei num_buffers;
25 struct ALbuffer *buffers[];
26 } ALbufferlistitem;
29 typedef struct ALsource {
30 /** Source properties. */
31 ALfloat Pitch;
32 ALfloat Gain;
33 ALfloat OuterGain;
34 ALfloat MinGain;
35 ALfloat MaxGain;
36 ALfloat InnerAngle;
37 ALfloat OuterAngle;
38 ALfloat RefDistance;
39 ALfloat MaxDistance;
40 ALfloat RolloffFactor;
41 ALfloat Position[3];
42 ALfloat Velocity[3];
43 ALfloat Direction[3];
44 ALfloat Orientation[2][3];
45 ALboolean HeadRelative;
46 ALboolean Looping;
47 DistanceModel mDistanceModel;
48 enum Resampler Resampler;
49 ALboolean DirectChannels;
50 enum SpatializeMode Spatialize;
52 ALboolean DryGainHFAuto;
53 ALboolean WetGainAuto;
54 ALboolean WetGainHFAuto;
55 ALfloat OuterGainHF;
57 ALfloat AirAbsorptionFactor;
58 ALfloat RoomRolloffFactor;
59 ALfloat DopplerFactor;
61 /* NOTE: Stereo pan angles are specified in radians, counter-clockwise
62 * rather than clockwise.
64 ALfloat StereoPan[2];
66 ALfloat Radius;
68 /** Direct filter and auxiliary send info. */
69 struct {
70 ALfloat Gain;
71 ALfloat GainHF;
72 ALfloat HFReference;
73 ALfloat GainLF;
74 ALfloat LFReference;
75 } Direct;
76 struct SendData {
77 struct ALeffectslot *Slot;
78 ALfloat Gain;
79 ALfloat GainHF;
80 ALfloat HFReference;
81 ALfloat GainLF;
82 ALfloat LFReference;
84 al::vector<SendData> Send;
86 /**
87 * Last user-specified offset, and the offset type (bytes, samples, or
88 * seconds).
90 ALdouble Offset;
91 ALenum OffsetType;
93 /** Source type (static, streaming, or undetermined) */
94 ALint SourceType;
96 /** Source state (initial, playing, paused, or stopped) */
97 ALenum state;
99 /** Source Buffer Queue head. */
100 ALbufferlistitem *queue;
102 std::atomic_flag PropsClean{true};
104 /* Index into the context's Voices array. Lazily updated, only checked and
105 * reset when looking up the voice.
107 ALint VoiceIdx;
109 /** Self ID */
110 ALuint id;
113 ALsource(ALsizei num_sends);
114 ~ALsource();
116 ALsource(const ALsource&) = delete;
117 ALsource& operator=(const ALsource&) = delete;
118 } ALsource;
120 void UpdateAllSourceProps(ALCcontext *context);
122 #ifdef __cplusplus
124 #endif
126 #endif