219 lines
5.7 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;
2016-05-14 23:43:40 -07:00
struct ALsourceProps;
typedef struct ALbufferlistitem {
struct ALbuffer *buffer;
struct ALbufferlistitem *volatile next;
2007-11-13 18:02:18 -08:00
} ALbufferlistitem;
2014-08-21 03:24:48 -07:00
typedef struct ALvoice {
struct ALsource *volatile Source;
/** Current target parameters used for mixing. */
ALint Step;
2016-05-14 23:43:40 -07:00
ALboolean Looping;
/* If not 'moving', gain/coefficients are set directly without fading. */
ALboolean Moving;
ALboolean IsHrtf;
ALuint Offset; /* Number of output samples mixed since starting. */
alignas(16) ALfloat PrevSamples[MAX_INPUT_CHANNELS][MAX_PRE_SAMPLES];
BsincState SincState;
DirectParams Direct;
SendParams Send[MAX_SENDS];
2014-08-21 03:24:48 -07:00
} ALvoice;
2016-05-14 23:43:40 -07:00
struct ALsourceProps {
ATOMIC(ALfloat) Pitch;
ATOMIC(ALfloat) Gain;
ATOMIC(ALfloat) OuterGain;
ATOMIC(ALfloat) MinGain;
ATOMIC(ALfloat) MaxGain;
ATOMIC(ALfloat) InnerAngle;
ATOMIC(ALfloat) OuterAngle;
ATOMIC(ALfloat) RefDistance;
ATOMIC(ALfloat) MaxDistance;
ATOMIC(ALfloat) RollOffFactor;
ATOMIC(ALfloat) Position[3];
ATOMIC(ALfloat) Velocity[3];
ATOMIC(ALfloat) Direction[3];
ATOMIC(ALfloat) Orientation[2][3];
ATOMIC(ALboolean) HeadRelative;
ATOMIC(ALboolean) Looping;
ATOMIC(enum DistanceModel) DistanceModel;
ATOMIC(ALboolean) DirectChannels;
ATOMIC(ALboolean) DryGainHFAuto;
ATOMIC(ALboolean) WetGainAuto;
ATOMIC(ALboolean) WetGainHFAuto;
ATOMIC(ALfloat) OuterGainHF;
ATOMIC(ALfloat) AirAbsorptionFactor;
ATOMIC(ALfloat) RoomRolloffFactor;
ATOMIC(ALfloat) DopplerFactor;
ATOMIC(ALfloat) StereoPan[2];
ATOMIC(ALfloat) Radius;
/** Direct filter and auxiliary send info. */
struct {
ATOMIC(ALfloat) Gain;
ATOMIC(ALfloat) GainHF;
ATOMIC(ALfloat) HFReference;
ATOMIC(ALfloat) GainLF;
ATOMIC(ALfloat) LFReference;
} Direct;
struct {
ATOMIC(struct ALeffectslot*) Slot;
ATOMIC(ALfloat) Gain;
ATOMIC(ALfloat) GainHF;
ATOMIC(ALfloat) HFReference;
ATOMIC(ALfloat) GainLF;
ATOMIC(ALfloat) LFReference;
} Send[MAX_SENDS];
ATOMIC(struct ALsourceProps*) next;
};
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;
2016-05-14 23:43:40 -07:00
volatile ALfloat Position[3];
volatile ALfloat Velocity[3];
volatile ALfloat Direction[3];
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;
2016-03-25 14:40:44 -07:00
/* NOTE: Stereo pan angles are specified in radians, counter-clockwise
* rather than clockwise.
*/
volatile ALfloat StereoPan[2];
volatile 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 {
struct ALeffectslot *Slot;
ALfloat Gain;
ALfloat GainHF;
ALfloat HFReference;
ALfloat GainLF;
ALfloat LFReference;
} Send[MAX_SENDS];
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.
*/
2016-05-19 20:50:55 -07:00
ATOMIC(ALuint) position;
ATOMIC(ALuint) position_fraction;
2012-04-26 03:26:22 -07:00
/** 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;
2016-05-14 23:43:40 -07:00
ATOMIC(struct ALsourceProps*) Update;
ATOMIC(struct ALsourceProps*) FreeList;
2012-04-26 03:26:22 -07:00
/** Self ID */
ALuint id;
2007-11-13 18:02:18 -08:00
} ALsource;
inline void LockSourcesRead(ALCcontext *context)
{ LockUIntMapRead(&context->SourceMap); }
inline void UnlockSourcesRead(ALCcontext *context)
{ UnlockUIntMapRead(&context->SourceMap); }
inline void LockSourcesWrite(ALCcontext *context)
{ LockUIntMapWrite(&context->SourceMap); }
inline void UnlockSourcesWrite(ALCcontext *context)
{ UnlockUIntMapWrite(&context->SourceMap); }
inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
{ return (struct ALsource*)LookupUIntMapKeyNoLock(&context->SourceMap, id); }
inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
{ return (struct ALsource*)RemoveUIntMapKeyNoLock(&context->SourceMap, id); }
2016-05-14 23:43:40 -07:00
void UpdateAllSourceProps(ALCcontext *context);
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