openal-soft/al/source.h

130 lines
2.8 KiB
C
Raw Normal View History

2019-07-28 21:29:59 -07:00
#ifndef AL_SOURCE_H
#define AL_SOURCE_H
2007-11-13 18:02:18 -08:00
#include <array>
2019-07-28 21:29:59 -07:00
#include <atomic>
#include <cstddef>
#include <iterator>
2019-07-28 21:29:59 -07:00
#include "AL/al.h"
#include "AL/alc.h"
2007-11-13 18:02:18 -08:00
2019-07-28 21:29:59 -07:00
#include "alcontext.h"
#include "almalloc.h"
2019-07-28 21:29:59 -07:00
#include "alnumeric.h"
#include "alu.h"
#include "vector.h"
struct ALbuffer;
struct ALeffectslot;
2019-07-28 21:29:59 -07:00
#define DEFAULT_SENDS 2
2019-08-02 12:38:20 -07:00
#define INVALID_VOICE_IDX static_cast<ALuint>(-1)
2019-07-28 21:29:59 -07:00
struct ALbufferlistitem {
std::atomic<ALbufferlistitem*> mNext{nullptr};
ALuint mSampleLen{0u};
ALbuffer *mBuffer{nullptr};
DEF_NEWDEL(ALbufferlistitem)
};
2007-11-13 18:02:18 -08:00
struct ALsource {
2012-04-26 03:26:22 -07:00
/** Source properties. */
ALfloat Pitch;
ALfloat Gain;
ALfloat OuterGain;
ALfloat MinGain;
ALfloat MaxGain;
ALfloat InnerAngle;
ALfloat OuterAngle;
ALfloat RefDistance;
ALfloat MaxDistance;
2017-05-05 03:19:50 -07:00
ALfloat RolloffFactor;
std::array<ALfloat,3> Position;
std::array<ALfloat,3> Velocity;
std::array<ALfloat,3> Direction;
std::array<ALfloat,3> OrientAt;
std::array<ALfloat,3> OrientUp;
bool HeadRelative;
bool Looping;
DistanceModel mDistanceModel;
Resampler mResampler;
bool DirectChannels;
SpatializeMode mSpatialize;
bool DryGainHFAuto;
bool WetGainAuto;
bool WetGainHFAuto;
ALfloat OuterGainHF;
ALfloat AirAbsorptionFactor;
ALfloat RoomRolloffFactor;
ALfloat DopplerFactor;
2016-03-25 14:40:44 -07:00
/* NOTE: Stereo pan angles are specified in radians, counter-clockwise
* rather than clockwise.
*/
std::array<ALfloat,2> StereoPan;
2016-03-25 14:40:44 -07:00
ALfloat Radius;
2016-05-14 23:43:40 -07:00
/** Direct filter and auxiliary send info. */
struct {
ALfloat Gain;
ALfloat GainHF;
ALfloat HFReference;
ALfloat GainLF;
ALfloat LFReference;
} Direct;
struct SendData {
ALeffectslot *Slot;
2016-05-14 23:43:40 -07:00
ALfloat Gain;
ALfloat GainHF;
ALfloat HFReference;
ALfloat GainLF;
ALfloat LFReference;
};
al::vector<SendData> Send;
2016-05-14 23:43:40 -07:00
2012-04-26 03:26:22 -07:00
/**
* Last user-specified offset, and the offset type (bytes, samples, or
* seconds).
*/
2019-08-02 12:38:20 -07:00
ALdouble Offset{0.0};
ALenum OffsetType{AL_NONE};
2007-11-13 18:02:18 -08:00
2012-04-26 03:26:22 -07:00
/** Source type (static, streaming, or undetermined) */
ALenum SourceType{AL_UNDETERMINED};
2007-11-13 18:02:18 -08:00
2012-04-26 03:26:22 -07:00
/** Source state (initial, playing, paused, or stopped) */
2019-08-02 12:38:20 -07:00
ALenum state{AL_INITIAL};
2012-04-26 03:26:22 -07:00
/** Source Buffer Queue head. */
2019-08-02 12:38:20 -07:00
ALbufferlistitem *queue{nullptr};
std::atomic_flag PropsClean;
/* Index into the context's Voices array. Lazily updated, only checked and
* reset when looking up the voice.
*/
2019-08-02 12:38:20 -07:00
ALuint VoiceIdx{INVALID_VOICE_IDX};
2012-04-26 03:26:22 -07:00
/** Self ID */
2019-08-02 12:38:20 -07:00
ALuint id{0};
2019-09-13 04:15:05 -07:00
ALsource(ALuint num_sends);
~ALsource();
ALsource(const ALsource&) = delete;
ALsource& operator=(const ALsource&) = delete;
};
2007-11-13 18:02:18 -08:00
2016-05-14 23:43:40 -07:00
void UpdateAllSourceProps(ALCcontext *context);
2007-11-13 18:02:18 -08:00
#endif