13 #include "alcontext.h"
15 #include "alnumeric.h"
17 #include "math_defs.h"
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
)
38 /** Source properties. */
41 float OuterGain
{0.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};
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
)}};
77 /** Direct filter and auxiliary send info. */
93 std::array
<SendData
,MAX_SENDS
> Send
;
96 * Last user-specified offset, and the offset type (bytes, samples, or
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
};
125 ALsource(const ALsource
&) = delete;
126 ALsource
& operator=(const ALsource
&) = delete;
131 void UpdateAllSourceProps(ALCcontext
*context
);