147 lines
3.6 KiB
C
Raw Normal View History

2007-11-13 18:02:18 -08:00
#ifndef _AL_SOURCE_H_
#define _AL_SOURCE_H_
#define MAX_SENDS 4
2012-09-14 02:42:36 -07:00
#include "alMain.h"
#include "alu.h"
#include "hrtf.h"
2007-11-13 18:02:18 -08:00
#ifdef __cplusplus
extern "C" {
#endif
struct ALbuffer;
struct ALsource;
typedef struct ALbufferlistitem {
struct ALbuffer *buffer;
struct ALbufferlistitem *volatile next;
struct ALbufferlistitem *volatile prev;
2007-11-13 18:02:18 -08:00
} ALbufferlistitem;
2014-08-21 03:24:48 -07:00
typedef struct ALvoice {
struct ALsource *volatile Source;
/** 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);
/** Current target parameters used for mixing. */
ALint Step;
ALboolean IsHrtf;
ALuint Offset; /* Number of output samples mixed since starting. */
alignas(16) ALfloat PrevSamples[MAX_INPUT_CHANNELS][MAX_PRE_SAMPLES];
DirectParams Direct;
SendParams Send[MAX_SENDS];
2014-08-21 03:24:48 -07:00
} ALvoice;
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;
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;
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;
2011-09-11 01:18:57 -07:00
volatile ALfloat AirAbsorptionFactor;
volatile ALfloat RoomRolloffFactor;
volatile ALfloat DopplerFactor;
volatile ALfloat Radius;
2012-04-26 03:26:22 -07:00
/**
* Last user-specified offset, and the offset type (bytes, samples, or
* seconds).
*/
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. */
ATOMIC(ALbufferlistitem*) queue;
ATOMIC(ALbufferlistitem*) current_buffer;
RWLock queue_lock;
2012-04-26 03:26:22 -07:00
/** Current buffer sample info. */
ALuint NumChannels;
ALuint SampleSize;
2012-04-26 03:26:22 -07:00
/** Direct filter and auxiliary send info. */
struct {
ALfloat Gain;
ALfloat GainHF;
ALfloat HFReference;
ALfloat GainLF;
ALfloat LFReference;
} 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;
ALfloat HFReference;
ALfloat GainLF;
ALfloat LFReference;
2012-04-26 03:26:22 -07:00
} Send[MAX_SENDS];
/** Source needs to update its mixing parameters. */
ATOMIC(ALenum) NeedsUpdate;
2012-04-26 03:26:22 -07:00
/** Self ID */
ALuint id;
2007-11-13 18:02:18 -08:00
} ALsource;
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); }
ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
ALboolean ApplyOffset(ALsource *Source);
ALvoid ReleaseALSources(ALCcontext *Context);
2007-11-13 18:02:18 -08:00
#ifdef __cplusplus
}
#endif
#endif