Cast the ringbuffer size to the correct type
[openal-soft.git] / al / source.h
blob8417688a81c82d9b8974a803dcf88ed47661bcd6
1 #ifndef AL_SOURCE_H
2 #define AL_SOURCE_H
4 #include <array>
5 #include <atomic>
6 #include <cstddef>
7 #include <iterator>
8 #include <limits>
10 #include "AL/al.h"
11 #include "AL/alc.h"
13 #include "alcontext.h"
14 #include "almalloc.h"
15 #include "alnumeric.h"
16 #include "alu.h"
17 #include "math_defs.h"
18 #include "vector.h"
20 struct ALbuffer;
21 struct ALeffectslot;
24 #define DEFAULT_SENDS 2
26 #define INVALID_VOICE_IDX static_cast<ALuint>(-1)
28 struct ALbufferlistitem {
29 std::atomic<ALbufferlistitem*> mNext{nullptr};
30 ALuint mSampleLen{0u};
31 ALbuffer *mBuffer{nullptr};
33 DEF_NEWDEL(ALbufferlistitem)
37 struct ALsource {
38 /** Source properties. */
39 float Pitch{1.0f};
40 float Gain{1.0f};
41 float OuterGain{0.0f};
42 float MinGain{0.0f};
43 float MaxGain{1.0f};
44 float InnerAngle{360.0f};
45 float OuterAngle{360.0f};
46 float RefDistance{1.0f};
47 float MaxDistance{std::numeric_limits<float>::max()};
48 float RolloffFactor{1.0f};
49 std::array<float,3> Position{{0.0f, 0.0f, 0.0f}};
50 std::array<float,3> Velocity{{0.0f, 0.0f, 0.0f}};
51 std::array<float,3> Direction{{0.0f, 0.0f, 0.0f}};
52 std::array<float,3> OrientAt{{0.0f, 0.0f, -1.0f}};
53 std::array<float,3> OrientUp{{0.0f, 1.0f, 0.0f}};
54 bool HeadRelative{false};
55 bool Looping{false};
56 DistanceModel mDistanceModel{DistanceModel::Default};
57 Resampler mResampler{ResamplerDefault};
58 DirectMode DirectChannels{DirectMode::Off};
59 SpatializeMode mSpatialize{SpatializeMode::Auto};
61 bool DryGainHFAuto{true};
62 bool WetGainAuto{true};
63 bool WetGainHFAuto{true};
64 float OuterGainHF{1.0f};
66 float AirAbsorptionFactor{0.0f};
67 float RoomRolloffFactor{0.0f};
68 float DopplerFactor{1.0f};
70 /* NOTE: Stereo pan angles are specified in radians, counter-clockwise
71 * rather than clockwise.
73 std::array<float,2> StereoPan{{Deg2Rad( 30.0f), Deg2Rad(-30.0f)}};
75 float Radius{0.0f};
77 /** Direct filter and auxiliary send info. */
78 struct {
79 float Gain;
80 float GainHF;
81 float HFReference;
82 float GainLF;
83 float LFReference;
84 } Direct;
85 struct SendData {
86 ALeffectslot *Slot;
87 float Gain;
88 float GainHF;
89 float HFReference;
90 float GainLF;
91 float LFReference;
93 std::array<SendData,MAX_SENDS> Send;
95 /**
96 * Last user-specified offset, and the offset type (bytes, samples, or
97 * seconds).
99 double Offset{0.0};
100 ALenum OffsetType{AL_NONE};
102 /** Source type (static, streaming, or undetermined) */
103 ALenum SourceType{AL_UNDETERMINED};
105 /** Source state (initial, playing, paused, or stopped) */
106 ALenum state{AL_INITIAL};
108 /** Source Buffer Queue head. */
109 ALbufferlistitem *queue{nullptr};
111 std::atomic_flag PropsClean;
113 /* Index into the context's Voices array. Lazily updated, only checked and
114 * reset when looking up the voice.
116 ALuint VoiceIdx{INVALID_VOICE_IDX};
118 /** Self ID */
119 ALuint id{0};
122 ALsource();
123 ~ALsource();
125 ALsource(const ALsource&) = delete;
126 ALsource& operator=(const ALsource&) = delete;
128 DISABLE_ALLOC()
131 void UpdateAllSourceProps(ALCcontext *context);
133 #endif