Catch exceptions from backend start calls
[openal-soft.git] / al / source.h
blob7ca889d777c92e3d0ad021ac90fc9547bce3add9
1 #ifndef AL_SOURCE_H
2 #define AL_SOURCE_H
4 #include <array>
5 #include <atomic>
6 #include <cstddef>
7 #include <iterator>
9 #include "AL/al.h"
10 #include "AL/alc.h"
12 #include "alcontext.h"
13 #include "almalloc.h"
14 #include "alnumeric.h"
15 #include "alu.h"
16 #include "vector.h"
18 struct ALbuffer;
19 struct ALeffectslot;
22 #define DEFAULT_SENDS 2
24 #define INVALID_VOICE_IDX static_cast<ALuint>(-1)
26 struct ALbufferlistitem {
27 std::atomic<ALbufferlistitem*> mNext{nullptr};
28 ALuint mSampleLen{0u};
29 ALbuffer *mBuffer{nullptr};
31 DEF_NEWDEL(ALbufferlistitem)
35 struct ALsource {
36 /** Source properties. */
37 ALfloat Pitch;
38 ALfloat Gain;
39 ALfloat OuterGain;
40 ALfloat MinGain;
41 ALfloat MaxGain;
42 ALfloat InnerAngle;
43 ALfloat OuterAngle;
44 ALfloat RefDistance;
45 ALfloat MaxDistance;
46 ALfloat RolloffFactor;
47 std::array<ALfloat,3> Position;
48 std::array<ALfloat,3> Velocity;
49 std::array<ALfloat,3> Direction;
50 std::array<ALfloat,3> OrientAt;
51 std::array<ALfloat,3> OrientUp;
52 bool HeadRelative;
53 bool Looping;
54 DistanceModel mDistanceModel;
55 Resampler mResampler;
56 bool DirectChannels;
57 SpatializeMode mSpatialize;
59 bool DryGainHFAuto;
60 bool WetGainAuto;
61 bool WetGainHFAuto;
62 ALfloat OuterGainHF;
64 ALfloat AirAbsorptionFactor;
65 ALfloat RoomRolloffFactor;
66 ALfloat DopplerFactor;
68 /* NOTE: Stereo pan angles are specified in radians, counter-clockwise
69 * rather than clockwise.
71 std::array<ALfloat,2> StereoPan;
73 ALfloat Radius;
75 /** Direct filter and auxiliary send info. */
76 struct {
77 ALfloat Gain;
78 ALfloat GainHF;
79 ALfloat HFReference;
80 ALfloat GainLF;
81 ALfloat LFReference;
82 } Direct;
83 struct SendData {
84 ALeffectslot *Slot;
85 ALfloat Gain;
86 ALfloat GainHF;
87 ALfloat HFReference;
88 ALfloat GainLF;
89 ALfloat LFReference;
91 al::vector<SendData> Send;
93 /**
94 * Last user-specified offset, and the offset type (bytes, samples, or
95 * seconds).
97 ALdouble Offset{0.0};
98 ALenum OffsetType{AL_NONE};
100 /** Source type (static, streaming, or undetermined) */
101 ALenum SourceType{AL_UNDETERMINED};
103 /** Source state (initial, playing, paused, or stopped) */
104 ALenum state{AL_INITIAL};
106 /** Source Buffer Queue head. */
107 ALbufferlistitem *queue{nullptr};
109 std::atomic_flag PropsClean;
111 /* Index into the context's Voices array. Lazily updated, only checked and
112 * reset when looking up the voice.
114 ALuint VoiceIdx{INVALID_VOICE_IDX};
116 /** Self ID */
117 ALuint id{0};
120 ALsource(ALuint num_sends);
121 ~ALsource();
123 ALsource(const ALsource&) = delete;
124 ALsource& operator=(const ALsource&) = delete;
127 void UpdateAllSourceProps(ALCcontext *context);
129 #endif