2019-07-28 21:29:59 -07:00
|
|
|
#ifndef AL_SOURCE_H
|
|
|
|
#define AL_SOURCE_H
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-12-26 22:27:34 -08:00
|
|
|
#include <array>
|
2019-07-28 21:29:59 -07:00
|
|
|
#include <atomic>
|
|
|
|
#include <cstddef>
|
2019-07-31 09:20:53 -07:00
|
|
|
#include <iterator>
|
2018-12-26 22:27:34 -08:00
|
|
|
|
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"
|
2019-08-11 03:34:35 -07:00
|
|
|
#include "almalloc.h"
|
2019-07-28 21:29:59 -07:00
|
|
|
#include "alnumeric.h"
|
|
|
|
#include "alu.h"
|
|
|
|
#include "vector.h"
|
2017-03-02 00:49:03 -08:00
|
|
|
|
2014-08-20 21:35:18 -07:00
|
|
|
struct ALbuffer;
|
2018-12-24 19:29:01 -08:00
|
|
|
struct ALeffectslot;
|
2014-08-20 21:35:18 -07:00
|
|
|
|
2010-11-26 02:53:15 -08:00
|
|
|
|
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
|
|
|
|
2018-12-24 19:29:01 -08:00
|
|
|
struct ALbufferlistitem {
|
2019-08-11 03:34:35 -07:00
|
|
|
std::atomic<ALbufferlistitem*> mNext{nullptr};
|
|
|
|
ALuint mSampleLen{0u};
|
|
|
|
ALbuffer *mBuffer{nullptr};
|
2019-07-31 09:20:53 -07:00
|
|
|
|
2019-08-11 03:34:35 -07:00
|
|
|
DEF_NEWDEL(ALbufferlistitem)
|
2018-12-24 19:29:01 -08:00
|
|
|
};
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2014-03-18 19:56:25 -07:00
|
|
|
|
2018-12-24 19:29:01 -08:00
|
|
|
struct ALsource {
|
2012-04-26 03:26:22 -07:00
|
|
|
/** Source properties. */
|
2016-06-03 05:46:29 -07:00
|
|
|
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;
|
2018-12-26 22:27:34 -08:00
|
|
|
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;
|
2019-09-12 11:33:04 -07:00
|
|
|
bool HeadRelative;
|
|
|
|
bool Looping;
|
2018-11-18 03:39:32 -08:00
|
|
|
DistanceModel mDistanceModel;
|
2018-12-24 19:29:01 -08:00
|
|
|
Resampler mResampler;
|
2019-09-12 11:33:04 -07:00
|
|
|
bool DirectChannels;
|
2018-12-24 19:29:01 -08:00
|
|
|
SpatializeMode mSpatialize;
|
2016-06-03 05:46:29 -07:00
|
|
|
|
2019-09-12 11:33:04 -07:00
|
|
|
bool DryGainHFAuto;
|
|
|
|
bool WetGainAuto;
|
|
|
|
bool WetGainHFAuto;
|
|
|
|
ALfloat OuterGainHF;
|
2016-06-03 05:46:29 -07:00
|
|
|
|
|
|
|
ALfloat AirAbsorptionFactor;
|
|
|
|
ALfloat RoomRolloffFactor;
|
|
|
|
ALfloat DopplerFactor;
|
2008-07-15 02:33:05 -07:00
|
|
|
|
2016-03-25 14:40:44 -07:00
|
|
|
/* NOTE: Stereo pan angles are specified in radians, counter-clockwise
|
|
|
|
* rather than clockwise.
|
|
|
|
*/
|
2018-12-26 22:27:34 -08:00
|
|
|
std::array<ALfloat,2> StereoPan;
|
2016-03-25 14:40:44 -07:00
|
|
|
|
2016-06-03 05:46:29 -07:00
|
|
|
ALfloat Radius;
|
2014-07-08 09:13:35 -07:00
|
|
|
|
Provide asynchronous property updates for sources
This necessitates a change in how source updates are handled. Rather than just
being able to update sources when a dependent object state is changed (e.g. a
listener gain change), now all source updates must be proactively provided.
Consequently, apps that do not utilize any deferring (AL_SOFT_defer_updates or
alcSuspendContext/alcProcessContext) may utilize more CPU since it'll be
filling out more update containers for the mixer thread to use.
The upside is that there's less blocking between the app's calling thread and
the mixer thread, particularly for vectors and other multi-value properties
(filters and sends). Deferring behavior when used is also improved, since
updates that shouldn't be applied yet are simply not provided. And when they
are provided, the mixer doesn't have to ignore them, meaning the actual
deferring of a context doesn't have to synchrnously force an update -- the
process call will send any pending updates, which the mixer will apply even if
another deferral occurs before the mixer runs, because it'll still be there
waiting on the next mixer invocation.
There is one slight bug introduced by this commit. When a listener change is
made, or changes to multiple sources while updates are being deferred, it is
possible for the mixer to run while the sources are prepping their updates,
causing some of the source updates to be seen before the other. This will be
fixed in short order.
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;
|
2018-11-20 12:25:15 -08:00
|
|
|
struct SendData {
|
2018-12-24 19:29:01 -08:00
|
|
|
ALeffectslot *Slot;
|
Provide asynchronous property updates for sources
This necessitates a change in how source updates are handled. Rather than just
being able to update sources when a dependent object state is changed (e.g. a
listener gain change), now all source updates must be proactively provided.
Consequently, apps that do not utilize any deferring (AL_SOFT_defer_updates or
alcSuspendContext/alcProcessContext) may utilize more CPU since it'll be
filling out more update containers for the mixer thread to use.
The upside is that there's less blocking between the app's calling thread and
the mixer thread, particularly for vectors and other multi-value properties
(filters and sends). Deferring behavior when used is also improved, since
updates that shouldn't be applied yet are simply not provided. And when they
are provided, the mixer doesn't have to ignore them, meaning the actual
deferring of a context doesn't have to synchrnously force an update -- the
process call will send any pending updates, which the mixer will apply even if
another deferral occurs before the mixer runs, because it'll still be there
waiting on the next mixer invocation.
There is one slight bug introduced by this commit. When a listener change is
made, or changes to multiple sources while updates are being deferred, it is
possible for the mixer to run while the sources are prepping their updates,
causing some of the source updates to be seen before the other. This will be
fixed in short order.
2016-05-14 23:43:40 -07:00
|
|
|
ALfloat Gain;
|
|
|
|
ALfloat GainHF;
|
|
|
|
ALfloat HFReference;
|
|
|
|
ALfloat GainLF;
|
|
|
|
ALfloat LFReference;
|
2018-11-20 12:25:15 -08:00
|
|
|
};
|
|
|
|
al::vector<SendData> Send;
|
Provide asynchronous property updates for sources
This necessitates a change in how source updates are handled. Rather than just
being able to update sources when a dependent object state is changed (e.g. a
listener gain change), now all source updates must be proactively provided.
Consequently, apps that do not utilize any deferring (AL_SOFT_defer_updates or
alcSuspendContext/alcProcessContext) may utilize more CPU since it'll be
filling out more update containers for the mixer thread to use.
The upside is that there's less blocking between the app's calling thread and
the mixer thread, particularly for vectors and other multi-value properties
(filters and sends). Deferring behavior when used is also improved, since
updates that shouldn't be applied yet are simply not provided. And when they
are provided, the mixer doesn't have to ignore them, meaning the actual
deferring of a context doesn't have to synchrnously force an update -- the
process call will send any pending updates, which the mixer will apply even if
another deferral occurs before the mixer runs, because it'll still be there
waiting on the next mixer invocation.
There is one slight bug introduced by this commit. When a listener change is
made, or changes to multiple sources while updates are being deferred, it is
possible for the mixer to run while the sources are prepping their updates,
causing some of the source updates to be seen before the other. This will be
fixed in short order.
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) */
|
2019-09-12 11:33:04 -07:00
|
|
|
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
|
|
|
|
2017-02-27 15:35:15 -08:00
|
|
|
/** Source Buffer Queue head. */
|
2019-08-02 12:38:20 -07:00
|
|
|
ALbufferlistitem *queue{nullptr};
|
2016-07-31 23:42:30 -07:00
|
|
|
|
2019-02-04 19:59:19 -08:00
|
|
|
std::atomic_flag PropsClean;
|
2016-11-23 01:31:13 -08:00
|
|
|
|
2018-02-01 23:56:35 -08:00
|
|
|
/* 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};
|
2018-02-01 23:56:35 -08:00
|
|
|
|
2012-04-26 03:26:22 -07:00
|
|
|
/** Self ID */
|
2019-08-02 12:38:20 -07:00
|
|
|
ALuint id{0};
|
2018-11-20 12:25:15 -08:00
|
|
|
|
|
|
|
|
2019-09-13 04:15:05 -07:00
|
|
|
ALsource(ALuint num_sends);
|
2018-11-20 12:25:15 -08:00
|
|
|
~ALsource();
|
|
|
|
|
|
|
|
ALsource(const ALsource&) = delete;
|
|
|
|
ALsource& operator=(const ALsource&) = delete;
|
2018-12-24 19:29:01 -08:00
|
|
|
};
|
2007-11-13 18:02:18 -08:00
|
|
|
|
Provide asynchronous property updates for sources
This necessitates a change in how source updates are handled. Rather than just
being able to update sources when a dependent object state is changed (e.g. a
listener gain change), now all source updates must be proactively provided.
Consequently, apps that do not utilize any deferring (AL_SOFT_defer_updates or
alcSuspendContext/alcProcessContext) may utilize more CPU since it'll be
filling out more update containers for the mixer thread to use.
The upside is that there's less blocking between the app's calling thread and
the mixer thread, particularly for vectors and other multi-value properties
(filters and sends). Deferring behavior when used is also improved, since
updates that shouldn't be applied yet are simply not provided. And when they
are provided, the mixer doesn't have to ignore them, meaning the actual
deferring of a context doesn't have to synchrnously force an update -- the
process call will send any pending updates, which the mixer will apply even if
another deferral occurs before the mixer runs, because it'll still be there
waiting on the next mixer invocation.
There is one slight bug introduced by this commit. When a listener change is
made, or changes to multiple sources while updates are being deferred, it is
possible for the mixer to run while the sources are prepping their updates,
causing some of the source updates to be seen before the other. This will be
fixed in short order.
2016-05-14 23:43:40 -07:00
|
|
|
void UpdateAllSourceProps(ALCcontext *context);
|
2017-02-13 21:18:18 -08:00
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
#endif
|