2007-11-13 18:02:18 -08:00
|
|
|
#ifndef _AL_SOURCE_H_
|
|
|
|
#define _AL_SOURCE_H_
|
|
|
|
|
2012-09-14 02:42:36 -07:00
|
|
|
#include "alMain.h"
|
2008-08-14 05:43:52 -07:00
|
|
|
#include "alu.h"
|
2014-02-23 21:11:01 -08:00
|
|
|
#include "hrtf.h"
|
2017-04-19 19:54:17 -07:00
|
|
|
#include "atomic.h"
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2017-03-02 00:49:03 -08:00
|
|
|
#define MAX_SENDS 16
|
|
|
|
#define DEFAULT_SENDS 2
|
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-08-20 21:35:18 -07:00
|
|
|
struct ALbuffer;
|
|
|
|
struct ALsource;
|
|
|
|
|
2010-11-26 02:53:15 -08:00
|
|
|
|
2013-10-07 05:41:41 -07:00
|
|
|
typedef struct ALbufferlistitem {
|
2017-04-19 19:54:17 -07:00
|
|
|
ATOMIC(struct ALbufferlistitem*) next;
|
2018-03-27 08:27:16 -07:00
|
|
|
ALsizei max_samples;
|
2017-12-15 22:59:51 -08:00
|
|
|
ALsizei num_buffers;
|
|
|
|
struct ALbuffer *buffers[];
|
2007-11-13 18:02:18 -08:00
|
|
|
} ALbufferlistitem;
|
|
|
|
|
2014-03-18 19:56:25 -07:00
|
|
|
|
|
|
|
typedef 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;
|
2016-06-03 05:46:29 -07:00
|
|
|
ALfloat Position[3];
|
|
|
|
ALfloat Velocity[3];
|
|
|
|
ALfloat Direction[3];
|
|
|
|
ALfloat Orientation[2][3];
|
|
|
|
ALboolean HeadRelative;
|
2017-04-18 00:58:33 -07:00
|
|
|
ALboolean Looping;
|
2018-11-18 03:39:32 -08:00
|
|
|
DistanceModel mDistanceModel;
|
2017-04-21 00:06:40 -07:00
|
|
|
enum Resampler Resampler;
|
2016-06-03 05:46:29 -07:00
|
|
|
ALboolean DirectChannels;
|
2017-05-04 12:17:50 -07:00
|
|
|
enum SpatializeMode Spatialize;
|
2016-06-03 05:46:29 -07:00
|
|
|
|
|
|
|
ALboolean DryGainHFAuto;
|
|
|
|
ALboolean WetGainAuto;
|
|
|
|
ALboolean WetGainHFAuto;
|
|
|
|
ALfloat OuterGainHF;
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2016-06-03 05:46:29 -07:00
|
|
|
ALfloat StereoPan[2];
|
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;
|
|
|
|
struct {
|
|
|
|
struct ALeffectslot *Slot;
|
|
|
|
ALfloat Gain;
|
|
|
|
ALfloat GainHF;
|
|
|
|
ALfloat HFReference;
|
|
|
|
ALfloat GainLF;
|
|
|
|
ALfloat LFReference;
|
2017-02-21 16:31:59 -08:00
|
|
|
} *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).
|
|
|
|
*/
|
2012-04-16 22:11:03 -07:00
|
|
|
ALdouble Offset;
|
|
|
|
ALenum OffsetType;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-26 03:26:22 -07:00
|
|
|
/** Source type (static, streaming, or undetermined) */
|
2016-06-03 05:46:29 -07:00
|
|
|
ALint SourceType;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-26 03:26:22 -07:00
|
|
|
/** Source state (initial, playing, paused, or stopped) */
|
2018-02-24 09:44:52 -08:00
|
|
|
ALenum state;
|
2012-04-26 03:26:22 -07:00
|
|
|
|
2017-02-27 15:35:15 -08:00
|
|
|
/** Source Buffer Queue head. */
|
2017-04-18 00:58:33 -07:00
|
|
|
ALbufferlistitem *queue;
|
2016-07-31 23:42:30 -07:00
|
|
|
|
2018-11-20 10:45:01 -08:00
|
|
|
std::atomic_flag PropsClean{true};
|
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.
|
|
|
|
*/
|
|
|
|
ALint VoiceIdx;
|
|
|
|
|
2012-04-26 03:26:22 -07:00
|
|
|
/** Self ID */
|
2012-04-19 22:28:01 -07:00
|
|
|
ALuint id;
|
2007-11-13 18:02:18 -08:00
|
|
|
} ALsource;
|
|
|
|
|
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
|
|
|
|
2008-01-16 13:27:15 -08:00
|
|
|
ALvoid ReleaseALSources(ALCcontext *Context);
|
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|