2007-11-13 18:02:18 -08:00
|
|
|
#ifndef _AL_SOURCE_H_
|
|
|
|
#define _AL_SOURCE_H_
|
|
|
|
|
2010-11-06 15:08:54 -07:00
|
|
|
#define MAX_SENDS 4
|
2007-12-18 18:13:49 -08:00
|
|
|
|
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"
|
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 {
|
2014-07-31 07:20:36 -07:00
|
|
|
struct ALbuffer *buffer;
|
|
|
|
struct ALbufferlistitem *volatile next;
|
|
|
|
struct ALbufferlistitem *volatile prev;
|
2007-11-13 18:02:18 -08:00
|
|
|
} ALbufferlistitem;
|
|
|
|
|
2014-03-18 19:56:25 -07:00
|
|
|
|
2014-08-21 03:24:48 -07:00
|
|
|
typedef struct ALvoice {
|
2014-08-20 21:35:18 -07:00
|
|
|
struct ALsource *volatile Source;
|
2014-03-19 13:14:11 -07:00
|
|
|
|
|
|
|
/** Method to update mixing parameters. */
|
2014-08-21 03:24:48 -07:00
|
|
|
ALvoid (*Update)(struct ALvoice *self, const struct ALsource *source, const ALCcontext *context);
|
2014-03-19 13:14:11 -07:00
|
|
|
|
|
|
|
/** Current target parameters used for mixing. */
|
2014-06-13 16:07:25 -07:00
|
|
|
ALint Step;
|
2014-03-19 13:14:11 -07:00
|
|
|
|
2014-05-18 09:31:08 -07:00
|
|
|
ALboolean IsHrtf;
|
2014-03-19 13:14:11 -07:00
|
|
|
|
2014-05-24 16:55:10 -07:00
|
|
|
ALuint Offset; /* Number of output samples mixed since starting. */
|
|
|
|
|
2015-10-15 15:13:19 -07:00
|
|
|
alignas(16) ALfloat PrevSamples[MAX_INPUT_CHANNELS][MAX_PRE_SAMPLES];
|
2015-10-15 07:29:25 -07:00
|
|
|
|
2014-03-19 13:14:11 -07:00
|
|
|
DirectParams Direct;
|
|
|
|
SendParams Send[MAX_SENDS];
|
2014-08-21 03:24:48 -07:00
|
|
|
} ALvoice;
|
2014-03-19 13:14:11 -07:00
|
|
|
|
|
|
|
|
2014-03-18 19:56:25 -07:00
|
|
|
typedef struct ALsource {
|
2012-04-26 03:26:22 -07:00
|
|
|
/** Source properties. */
|
2012-04-19 21:46:29 -07:00
|
|
|
volatile ALfloat Pitch;
|
|
|
|
volatile ALfloat Gain;
|
|
|
|
volatile ALfloat OuterGain;
|
|
|
|
volatile ALfloat MinGain;
|
|
|
|
volatile ALfloat MaxGain;
|
|
|
|
volatile ALfloat InnerAngle;
|
|
|
|
volatile ALfloat OuterAngle;
|
|
|
|
volatile ALfloat RefDistance;
|
|
|
|
volatile ALfloat MaxDistance;
|
|
|
|
volatile ALfloat RollOffFactor;
|
2014-12-16 07:20:27 -08:00
|
|
|
aluVector Position;
|
|
|
|
aluVector Velocity;
|
|
|
|
aluVector Direction;
|
2014-10-31 22:43:13 -07:00
|
|
|
volatile ALfloat Orientation[2][3];
|
2012-04-19 21:46:29 -07:00
|
|
|
volatile ALboolean HeadRelative;
|
|
|
|
volatile ALboolean Looping;
|
2011-09-11 01:18:57 -07:00
|
|
|
volatile enum DistanceModel DistanceModel;
|
2012-02-09 23:35:17 -08:00
|
|
|
volatile ALboolean DirectChannels;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-11 01:18:57 -07:00
|
|
|
volatile ALboolean DryGainHFAuto;
|
|
|
|
volatile ALboolean WetGainAuto;
|
|
|
|
volatile ALboolean WetGainHFAuto;
|
|
|
|
volatile ALfloat OuterGainHF;
|
2007-12-17 21:33:05 -08:00
|
|
|
|
2011-09-11 01:18:57 -07:00
|
|
|
volatile ALfloat AirAbsorptionFactor;
|
|
|
|
volatile ALfloat RoomRolloffFactor;
|
|
|
|
volatile ALfloat DopplerFactor;
|
2008-07-15 02:33:05 -07:00
|
|
|
|
2014-07-08 09:13:35 -07:00
|
|
|
volatile ALfloat Radius;
|
|
|
|
|
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) */
|
2012-04-19 21:46:29 -07:00
|
|
|
volatile 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) */
|
|
|
|
volatile ALenum state;
|
|
|
|
ALenum new_state;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Source offset in samples, relative to the currently playing buffer, NOT
|
|
|
|
* the whole queue, and the fractional (fixed-point) offset to the next
|
|
|
|
* sample.
|
|
|
|
*/
|
|
|
|
ALuint position;
|
|
|
|
ALuint position_fraction;
|
|
|
|
|
|
|
|
/** Source Buffer Queue info. */
|
2014-07-31 07:20:36 -07:00
|
|
|
ATOMIC(ALbufferlistitem*) queue;
|
|
|
|
ATOMIC(ALbufferlistitem*) current_buffer;
|
2014-05-10 05:07:13 -07:00
|
|
|
RWLock queue_lock;
|
2012-04-26 03:26:22 -07:00
|
|
|
|
|
|
|
/** Current buffer sample info. */
|
2011-05-17 13:25:15 -07:00
|
|
|
ALuint NumChannels;
|
2011-05-18 17:02:18 -07:00
|
|
|
ALuint SampleSize;
|
2011-05-17 13:25:15 -07:00
|
|
|
|
2012-04-26 03:26:22 -07:00
|
|
|
/** Direct filter and auxiliary send info. */
|
2014-05-11 01:36:18 -07:00
|
|
|
struct {
|
|
|
|
ALfloat Gain;
|
|
|
|
ALfloat GainHF;
|
2014-05-11 10:07:17 -07:00
|
|
|
ALfloat HFReference;
|
2014-05-17 07:54:25 -07:00
|
|
|
ALfloat GainLF;
|
|
|
|
ALfloat LFReference;
|
2014-05-11 01:36:18 -07:00
|
|
|
} Direct;
|
2012-04-26 03:26:22 -07:00
|
|
|
struct {
|
|
|
|
struct ALeffectslot *Slot;
|
2012-04-27 00:45:42 -07:00
|
|
|
ALfloat Gain;
|
|
|
|
ALfloat GainHF;
|
2014-05-11 10:07:17 -07:00
|
|
|
ALfloat HFReference;
|
2014-05-17 07:54:25 -07:00
|
|
|
ALfloat GainLF;
|
|
|
|
ALfloat LFReference;
|
2012-04-26 03:26:22 -07:00
|
|
|
} Send[MAX_SENDS];
|
|
|
|
|
|
|
|
/** Source needs to update its mixing parameters. */
|
2014-07-21 23:14:48 -07:00
|
|
|
ATOMIC(ALenum) NeedsUpdate;
|
2010-09-26 01:15:27 -07:00
|
|
|
|
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;
|
|
|
|
|
2013-11-04 13:51:19 -08:00
|
|
|
inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
|
|
|
|
{ return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
|
|
|
|
inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
|
|
|
|
{ return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
|
|
|
|
|
2011-08-20 06:31:10 -07:00
|
|
|
ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
|
2011-08-21 00:49:04 -07:00
|
|
|
ALboolean ApplyOffset(ALsource *Source);
|
|
|
|
|
2008-01-16 13:27:15 -08:00
|
|
|
ALvoid ReleaseALSources(ALCcontext *Context);
|
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|