mirror of
https://github.com/love2d/love-android.git
synced 2026-08-20 04:31:26 +02:00
added dependencies and build files (loosely inspired by Sebastian Dorda's love-native-android)
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
#ifndef _AL_AUXEFFECTSLOT_H_
|
||||
#define _AL_AUXEFFECTSLOT_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "alEffect.h"
|
||||
#include "alFilter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ALeffectState ALeffectState;
|
||||
|
||||
typedef struct ALeffectslot
|
||||
{
|
||||
ALeffect effect;
|
||||
|
||||
volatile ALfloat Gain;
|
||||
volatile ALboolean AuxSendAuto;
|
||||
|
||||
volatile ALenum NeedsUpdate;
|
||||
ALeffectState *EffectState;
|
||||
|
||||
ALfloat WetBuffer[BUFFERSIZE];
|
||||
|
||||
ALfloat ClickRemoval[1];
|
||||
ALfloat PendingClicks[1];
|
||||
|
||||
RefCount ref;
|
||||
|
||||
// Index to itself
|
||||
ALuint effectslot;
|
||||
|
||||
struct ALeffectslot *next;
|
||||
} ALeffectslot;
|
||||
|
||||
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
|
||||
|
||||
|
||||
struct ALeffectState {
|
||||
ALvoid (*Destroy)(ALeffectState *State);
|
||||
ALboolean (*DeviceUpdate)(ALeffectState *State, ALCdevice *Device);
|
||||
ALvoid (*Update)(ALeffectState *State, ALCcontext *Context, const ALeffectslot *Slot);
|
||||
ALvoid (*Process)(ALeffectState *State, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]);
|
||||
};
|
||||
|
||||
ALeffectState *NoneCreate(void);
|
||||
ALeffectState *ReverbCreate(void);
|
||||
ALeffectState *EchoCreate(void);
|
||||
ALeffectState *ModulatorCreate(void);
|
||||
ALeffectState *DedicatedCreate(void);
|
||||
|
||||
#define ALeffectState_Destroy(a) ((a)->Destroy((a)))
|
||||
#define ALeffectState_DeviceUpdate(a,b) ((a)->DeviceUpdate((a),(b)))
|
||||
#define ALeffectState_Update(a,b,c) ((a)->Update((a),(b),(c)))
|
||||
#define ALeffectState_Process(a,b,c,d) ((a)->Process((a),(b),(c),(d)))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,101 @@
|
||||
#ifndef _AL_BUFFER_H_
|
||||
#define _AL_BUFFER_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* User formats */
|
||||
enum UserFmtType {
|
||||
UserFmtByte = AL_BYTE,
|
||||
UserFmtUByte = AL_UNSIGNED_BYTE,
|
||||
UserFmtShort = AL_SHORT,
|
||||
UserFmtUShort = AL_UNSIGNED_SHORT,
|
||||
UserFmtInt = AL_INT,
|
||||
UserFmtUInt = AL_UNSIGNED_INT,
|
||||
UserFmtFloat = AL_FLOAT,
|
||||
UserFmtDouble = AL_DOUBLE,
|
||||
UserFmtMulaw = AL_MULAW,
|
||||
UserFmtAlaw = AL_ALAW,
|
||||
UserFmtIMA4 = AL_IMA4,
|
||||
UserFmtByte3 = AL_BYTE3,
|
||||
UserFmtUByte3 = AL_UNSIGNED_BYTE3,
|
||||
};
|
||||
enum UserFmtChannels {
|
||||
UserFmtMono = AL_MONO,
|
||||
UserFmtStereo = AL_STEREO,
|
||||
UserFmtRear = AL_REAR,
|
||||
UserFmtQuad = AL_QUAD,
|
||||
UserFmtX51 = AL_5POINT1, /* (WFX order) */
|
||||
UserFmtX61 = AL_6POINT1, /* (WFX order) */
|
||||
UserFmtX71 = AL_7POINT1 /* (WFX order) */
|
||||
};
|
||||
|
||||
ALuint BytesFromUserFmt(enum UserFmtType type);
|
||||
ALuint ChannelsFromUserFmt(enum UserFmtChannels chans);
|
||||
static __inline ALuint FrameSizeFromUserFmt(enum UserFmtChannels chans,
|
||||
enum UserFmtType type)
|
||||
{
|
||||
return ChannelsFromUserFmt(chans) * BytesFromUserFmt(type);
|
||||
}
|
||||
|
||||
|
||||
/* Storable formats */
|
||||
enum FmtType {
|
||||
FmtByte = UserFmtByte,
|
||||
FmtShort = UserFmtShort,
|
||||
FmtFloat = UserFmtFloat,
|
||||
};
|
||||
enum FmtChannels {
|
||||
FmtMono = UserFmtMono,
|
||||
FmtStereo = UserFmtStereo,
|
||||
FmtRear = UserFmtRear,
|
||||
FmtQuad = UserFmtQuad,
|
||||
FmtX51 = UserFmtX51,
|
||||
FmtX61 = UserFmtX61,
|
||||
FmtX71 = UserFmtX71,
|
||||
};
|
||||
|
||||
ALuint BytesFromFmt(enum FmtType type);
|
||||
ALuint ChannelsFromFmt(enum FmtChannels chans);
|
||||
static __inline ALuint FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type)
|
||||
{
|
||||
return ChannelsFromFmt(chans) * BytesFromFmt(type);
|
||||
}
|
||||
|
||||
|
||||
typedef struct ALbuffer
|
||||
{
|
||||
ALvoid *data;
|
||||
|
||||
ALsizei Frequency;
|
||||
ALenum Format;
|
||||
ALsizei SampleLen;
|
||||
|
||||
enum FmtChannels FmtChannels;
|
||||
enum FmtType FmtType;
|
||||
|
||||
enum UserFmtChannels OriginalChannels;
|
||||
enum UserFmtType OriginalType;
|
||||
ALsizei OriginalSize;
|
||||
|
||||
ALsizei LoopStart;
|
||||
ALsizei LoopEnd;
|
||||
|
||||
RefCount ref; // Number of sources using this buffer (deletion can only occur when this is 0)
|
||||
|
||||
RWLock lock;
|
||||
|
||||
// Index to itself
|
||||
ALuint buffer;
|
||||
} ALbuffer;
|
||||
|
||||
ALvoid ReleaseALBuffers(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,111 @@
|
||||
#ifndef _AL_EFFECT_H_
|
||||
#define _AL_EFFECT_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
EAXREVERB = 0,
|
||||
REVERB,
|
||||
ECHO,
|
||||
MODULATOR,
|
||||
DEDICATED,
|
||||
|
||||
MAX_EFFECTS
|
||||
};
|
||||
extern ALboolean DisabledEffects[MAX_EFFECTS];
|
||||
|
||||
extern ALfloat ReverbBoost;
|
||||
extern ALboolean EmulateEAXReverb;
|
||||
|
||||
typedef struct ALeffect
|
||||
{
|
||||
// Effect type (AL_EFFECT_NULL, ...)
|
||||
ALenum type;
|
||||
|
||||
struct {
|
||||
// Shared Reverb Properties
|
||||
ALfloat Density;
|
||||
ALfloat Diffusion;
|
||||
ALfloat Gain;
|
||||
ALfloat GainHF;
|
||||
ALfloat DecayTime;
|
||||
ALfloat DecayHFRatio;
|
||||
ALfloat ReflectionsGain;
|
||||
ALfloat ReflectionsDelay;
|
||||
ALfloat LateReverbGain;
|
||||
ALfloat LateReverbDelay;
|
||||
ALfloat AirAbsorptionGainHF;
|
||||
ALfloat RoomRolloffFactor;
|
||||
ALboolean DecayHFLimit;
|
||||
|
||||
// Additional EAX Reverb Properties
|
||||
ALfloat GainLF;
|
||||
ALfloat DecayLFRatio;
|
||||
ALfloat ReflectionsPan[3];
|
||||
ALfloat LateReverbPan[3];
|
||||
ALfloat EchoTime;
|
||||
ALfloat EchoDepth;
|
||||
ALfloat ModulationTime;
|
||||
ALfloat ModulationDepth;
|
||||
ALfloat HFReference;
|
||||
ALfloat LFReference;
|
||||
} Reverb;
|
||||
|
||||
struct {
|
||||
ALfloat Delay;
|
||||
ALfloat LRDelay;
|
||||
|
||||
ALfloat Damping;
|
||||
ALfloat Feedback;
|
||||
|
||||
ALfloat Spread;
|
||||
} Echo;
|
||||
|
||||
struct {
|
||||
ALfloat Frequency;
|
||||
ALfloat HighPassCutoff;
|
||||
ALint Waveform;
|
||||
} Modulator;
|
||||
|
||||
struct {
|
||||
ALfloat Gain;
|
||||
} Dedicated;
|
||||
|
||||
void (*SetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
|
||||
void (*SetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
|
||||
void (*SetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
|
||||
void (*SetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
|
||||
|
||||
void (*GetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
|
||||
void (*GetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
|
||||
void (*GetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
|
||||
void (*GetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
|
||||
|
||||
// Index to itself
|
||||
ALuint effect;
|
||||
} ALeffect;
|
||||
|
||||
#define ALeffect_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v)))
|
||||
#define ALeffect_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v)))
|
||||
#define ALeffect_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v)))
|
||||
#define ALeffect_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v)))
|
||||
|
||||
#define ALeffect_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v)))
|
||||
#define ALeffect_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v)))
|
||||
#define ALeffect_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v)))
|
||||
#define ALeffect_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v)))
|
||||
|
||||
static __inline ALboolean IsReverbEffect(ALenum type)
|
||||
{ return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
|
||||
|
||||
ALvoid ReleaseALEffects(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _AL_ERROR_H_
|
||||
#define _AL_ERROR_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ALboolean TrapALError;
|
||||
|
||||
ALvoid alSetError(ALCcontext *Context, ALenum errorCode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,110 @@
|
||||
#ifndef _AL_FILTER_H_
|
||||
#define _AL_FILTER_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "alu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
ALfloat coeff;
|
||||
#ifndef _MSC_VER
|
||||
ALfloat history[0];
|
||||
#else
|
||||
ALfloat history[1];
|
||||
#endif
|
||||
} FILTER;
|
||||
|
||||
static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset*2];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
output = output + (history[1]-output)*a;
|
||||
history[1] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
static __inline ALfloat lpFilter1P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
const ALfloat *history = &iir->history[offset*2];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
output = output + (history[1]-output)*a;
|
||||
|
||||
return output;
|
||||
}
|
||||
static __inline ALfloat lpFilter1PC(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
const ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/* Calculates the low-pass filter coefficient given the pre-scaled gain and
|
||||
* cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole,
|
||||
* sqrt(gain) for four-pole, etc) */
|
||||
ALfloat lpCoeffCalc(ALfloat g, ALfloat cw);
|
||||
|
||||
|
||||
typedef struct ALfilter {
|
||||
// Filter type (AL_FILTER_NULL, ...)
|
||||
ALenum type;
|
||||
|
||||
ALfloat Gain;
|
||||
ALfloat GainHF;
|
||||
|
||||
void (*SetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint val);
|
||||
void (*SetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals);
|
||||
void (*SetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val);
|
||||
void (*SetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals);
|
||||
|
||||
void (*GetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *val);
|
||||
void (*GetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals);
|
||||
void (*GetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val);
|
||||
void (*GetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals);
|
||||
|
||||
// Index to itself
|
||||
ALuint filter;
|
||||
} ALfilter;
|
||||
|
||||
#define ALfilter_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v)))
|
||||
#define ALfilter_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v)))
|
||||
#define ALfilter_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v)))
|
||||
#define ALfilter_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v)))
|
||||
|
||||
#define ALfilter_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v)))
|
||||
#define ALfilter_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v)))
|
||||
#define ALfilter_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v)))
|
||||
#define ALfilter_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v)))
|
||||
|
||||
ALvoid ReleaseALFilters(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef _AL_LISTENER_H_
|
||||
#define _AL_LISTENER_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ALlistener_struct
|
||||
{
|
||||
volatile ALfloat Position[3];
|
||||
volatile ALfloat Velocity[3];
|
||||
volatile ALfloat Forward[3];
|
||||
volatile ALfloat Up[3];
|
||||
volatile ALfloat Gain;
|
||||
volatile ALfloat MetersPerUnit;
|
||||
} ALlistener;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,845 @@
|
||||
#ifndef AL_MAIN_H
|
||||
#define AL_MAIN_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_FENV_H
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FPU_CONTROL_H
|
||||
#include <fpu_control.h>
|
||||
#endif
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
|
||||
#ifndef ALC_SOFT_device_loopback
|
||||
#define ALC_SOFT_device_loopback 1
|
||||
#define ALC_FORMAT_CHANNELS_SOFT 0x1990
|
||||
#define ALC_FORMAT_TYPE_SOFT 0x1991
|
||||
|
||||
/* Sample types */
|
||||
#define ALC_BYTE 0x1400
|
||||
#define ALC_UNSIGNED_BYTE 0x1401
|
||||
#define ALC_SHORT 0x1402
|
||||
#define ALC_UNSIGNED_SHORT 0x1403
|
||||
#define ALC_INT 0x1404
|
||||
#define ALC_UNSIGNED_INT 0x1405
|
||||
#define ALC_FLOAT 0x1406
|
||||
|
||||
/* Channel configurations */
|
||||
#define ALC_MONO 0x1500
|
||||
#define ALC_STEREO 0x1501
|
||||
#define ALC_QUAD 0x1503
|
||||
#define ALC_5POINT1 0x1504 /* (WFX order) */
|
||||
#define ALC_6POINT1 0x1505 /* (WFX order) */
|
||||
#define ALC_7POINT1 0x1506 /* (WFX order) */
|
||||
|
||||
typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(void);
|
||||
typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type);
|
||||
typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
|
||||
#ifdef AL_ALEXT_PROTOTYPES
|
||||
ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void);
|
||||
ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type);
|
||||
ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef AL_SOFT_buffer_samples
|
||||
#define AL_SOFT_buffer_samples 1
|
||||
/* Sample types */
|
||||
#define AL_BYTE 0x1400
|
||||
#define AL_UNSIGNED_BYTE 0x1401
|
||||
#define AL_SHORT 0x1402
|
||||
#define AL_UNSIGNED_SHORT 0x1403
|
||||
#define AL_INT 0x1404
|
||||
#define AL_UNSIGNED_INT 0x1405
|
||||
#define AL_FLOAT 0x1406
|
||||
#define AL_DOUBLE 0x1407
|
||||
#define AL_BYTE3 0x1408
|
||||
#define AL_UNSIGNED_BYTE3 0x1409
|
||||
#define AL_MULAW 0x1410
|
||||
#define AL_ALAW 0x1411
|
||||
#define AL_IMA4 0x1412
|
||||
|
||||
/* Channel configurations */
|
||||
#define AL_MONO 0x1500
|
||||
#define AL_STEREO 0x1501
|
||||
#define AL_REAR 0x1502
|
||||
#define AL_QUAD 0x1503
|
||||
#define AL_5POINT1 0x1504 /* (WFX order) */
|
||||
#define AL_6POINT1 0x1505 /* (WFX order) */
|
||||
#define AL_7POINT1 0x1506 /* (WFX order) */
|
||||
|
||||
/* Storage formats */
|
||||
#define AL_MONO8 0x1100
|
||||
#define AL_MONO16 0x1101
|
||||
#define AL_MONO32F 0x10010
|
||||
#define AL_STEREO8 0x1102
|
||||
#define AL_STEREO16 0x1103
|
||||
#define AL_STEREO32F 0x10011
|
||||
#define AL_QUAD8 0x1204
|
||||
#define AL_QUAD16 0x1205
|
||||
#define AL_QUAD32F 0x1206
|
||||
#define AL_REAR8 0x1207
|
||||
#define AL_REAR16 0x1208
|
||||
#define AL_REAR32F 0x1209
|
||||
#define AL_5POINT1_8 0x120A
|
||||
#define AL_5POINT1_16 0x120B
|
||||
#define AL_5POINT1_32F 0x120C
|
||||
#define AL_6POINT1_8 0x120D
|
||||
#define AL_6POINT1_16 0x120E
|
||||
#define AL_6POINT1_32F 0x120F
|
||||
#define AL_7POINT1_8 0x1210
|
||||
#define AL_7POINT1_16 0x1211
|
||||
#define AL_7POINT1_32F 0x1212
|
||||
|
||||
/* Buffer attributes */
|
||||
#define AL_INTERNAL_FORMAT 0x2008
|
||||
#define AL_BYTE_LENGTH 0x2009
|
||||
#define AL_SAMPLE_LENGTH 0x200A
|
||||
#define AL_SEC_LENGTH 0x200B
|
||||
|
||||
typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
|
||||
typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
|
||||
typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
|
||||
typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum);
|
||||
#ifdef AL_ALEXT_PROTOTYPES
|
||||
AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
|
||||
ALuint samplerate, ALenum internalformat, ALsizei samples,
|
||||
ALenum channels, ALenum type, const ALvoid *data);
|
||||
AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
|
||||
ALsizei offset, ALsizei samples,
|
||||
ALenum channels, ALenum type, const ALvoid *data);
|
||||
AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer,
|
||||
ALsizei offset, ALsizei samples,
|
||||
ALenum channels, ALenum type, ALvoid *data);
|
||||
AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef AL_SOFT_non_virtual_channels
|
||||
#define AL_SOFT_non_virtual_channels 1
|
||||
#define AL_VIRTUAL_CHANNELS_SOFT 0x1033
|
||||
#endif
|
||||
|
||||
#ifndef AL_SOFT_deferred_updates
|
||||
#define AL_SOFT_deferred_updates 1
|
||||
#define AL_DEFERRED_UPDATES_SOFT 0xC002
|
||||
typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void);
|
||||
typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void);
|
||||
#ifdef AL_ALEXT_PROTOTYPES
|
||||
AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void);
|
||||
AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_STDINT_H)
|
||||
#include <stdint.h>
|
||||
typedef int64_t ALint64;
|
||||
typedef uint64_t ALuint64;
|
||||
#elif defined(HAVE___INT64)
|
||||
typedef __int64 ALint64;
|
||||
typedef unsigned __int64 ALuint64;
|
||||
#elif (SIZEOF_LONG == 8)
|
||||
typedef long ALint64;
|
||||
typedef unsigned long ALuint64;
|
||||
#elif (SIZEOF_LONG_LONG == 8)
|
||||
typedef long long ALint64;
|
||||
typedef unsigned long long ALuint64;
|
||||
#endif
|
||||
|
||||
typedef ptrdiff_t ALintptrEXT;
|
||||
typedef ptrdiff_t ALsizeiptrEXT;
|
||||
|
||||
#ifdef HAVE_GCC_FORMAT
|
||||
#define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
|
||||
#else
|
||||
#define PRINTF_STYLE(x, y)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_RESTRICT)
|
||||
#define RESTRICT restrict
|
||||
#elif defined(HAVE___RESTRICT)
|
||||
#define RESTRICT __restrict
|
||||
#else
|
||||
#define RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef DWORD pthread_key_t;
|
||||
int pthread_key_create(pthread_key_t *key, void (*callback)(void*));
|
||||
int pthread_key_delete(pthread_key_t key);
|
||||
void *pthread_getspecific(pthread_key_t key);
|
||||
int pthread_setspecific(pthread_key_t key, void *val);
|
||||
|
||||
#define HAVE_DYNLOAD 1
|
||||
void *LoadLib(const char *name);
|
||||
void CloseLib(void *handle);
|
||||
void *GetSymbol(void *handle, const char *name);
|
||||
|
||||
typedef LONG pthread_once_t;
|
||||
#define PTHREAD_ONCE_INIT 0
|
||||
void pthread_once(pthread_once_t *once, void (*callback)(void));
|
||||
|
||||
static __inline int sched_yield(void)
|
||||
{ SwitchToThread(); return 0; }
|
||||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0)
|
||||
|
||||
typedef pthread_mutex_t CRITICAL_SECTION;
|
||||
void InitializeCriticalSection(CRITICAL_SECTION *cs);
|
||||
void DeleteCriticalSection(CRITICAL_SECTION *cs);
|
||||
void EnterCriticalSection(CRITICAL_SECTION *cs);
|
||||
void LeaveCriticalSection(CRITICAL_SECTION *cs);
|
||||
|
||||
ALuint timeGetTime(void);
|
||||
void Sleep(ALuint t);
|
||||
|
||||
#if defined(HAVE_DLFCN_H)
|
||||
#define HAVE_DYNLOAD 1
|
||||
void *LoadLib(const char *name);
|
||||
void CloseLib(void *handle);
|
||||
void *GetSymbol(void *handle, const char *name);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
|
||||
typedef ALuint RefCount;
|
||||
static __inline RefCount IncrementRef(volatile RefCount *ptr)
|
||||
{ return __sync_add_and_fetch(ptr, 1); }
|
||||
static __inline RefCount DecrementRef(volatile RefCount *ptr)
|
||||
{ return __sync_sub_and_fetch(ptr, 1); }
|
||||
|
||||
static __inline int ExchangeInt(volatile int *ptr, int newval)
|
||||
{
|
||||
return __sync_lock_test_and_set(ptr, newval);
|
||||
}
|
||||
static __inline void *ExchangePtr(void *volatile*ptr, void *newval)
|
||||
{
|
||||
return __sync_lock_test_and_set(ptr, newval);
|
||||
}
|
||||
static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
|
||||
{
|
||||
return __sync_bool_compare_and_swap(ptr, oldval, newval);
|
||||
}
|
||||
static __inline ALboolean CompExchangePtr(void *volatile*ptr, void *oldval, void *newval)
|
||||
{
|
||||
return __sync_bool_compare_and_swap(ptr, oldval, newval);
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
|
||||
static __inline int xaddl(volatile int *dest, int incr)
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__("lock; xaddl %0,(%1)"
|
||||
: "=r" (ret)
|
||||
: "r" (dest), "0" (incr)
|
||||
: "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef int RefCount;
|
||||
static __inline RefCount IncrementRef(volatile RefCount *ptr)
|
||||
{ return xaddl(ptr, 1)+1; }
|
||||
static __inline RefCount DecrementRef(volatile RefCount *ptr)
|
||||
{ return xaddl(ptr, -1)-1; }
|
||||
|
||||
static __inline int ExchangeInt(volatile int *dest, int newval)
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__("lock; xchgl %0,(%1)"
|
||||
: "=r" (ret)
|
||||
: "r" (dest), "0" (newval)
|
||||
: "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline ALboolean CompExchangeInt(volatile int *dest, int oldval, int newval)
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__("lock; cmpxchgl %2,(%1)"
|
||||
: "=a" (ret)
|
||||
: "r" (dest), "r" (newval), "0" (oldval)
|
||||
: "memory");
|
||||
return ret == oldval;
|
||||
}
|
||||
|
||||
static __inline void *ExchangePtr(void *volatile*dest, void *newval)
|
||||
{
|
||||
void *ret;
|
||||
__asm__ __volatile__(
|
||||
#ifdef __i386__
|
||||
"lock; xchgl %0,(%1)"
|
||||
#else
|
||||
"lock; xchgq %0,(%1)"
|
||||
#endif
|
||||
: "=r" (ret)
|
||||
: "r" (dest), "0" (newval)
|
||||
: "memory"
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline ALboolean CompExchangePtr(void *volatile*dest, void *oldval, void *newval)
|
||||
{
|
||||
void *ret;
|
||||
__asm__ __volatile__(
|
||||
#ifdef __i386__
|
||||
"lock; cmpxchgl %2,(%1)"
|
||||
#else
|
||||
"lock; cmpxchgq %2,(%1)"
|
||||
#endif
|
||||
: "=a" (ret)
|
||||
: "r" (dest), "r" (newval), "0" (oldval)
|
||||
: "memory"
|
||||
);
|
||||
return ret == oldval;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
typedef LONG RefCount;
|
||||
static __inline RefCount IncrementRef(volatile RefCount *ptr)
|
||||
{ return InterlockedIncrement(ptr); }
|
||||
static __inline RefCount DecrementRef(volatile RefCount *ptr)
|
||||
{ return InterlockedDecrement(ptr); }
|
||||
|
||||
extern ALbyte LONG_size_does_not_match_int[(sizeof(LONG)==sizeof(int))?1:-1];
|
||||
|
||||
static __inline int ExchangeInt(volatile int *ptr, int newval)
|
||||
{
|
||||
union {
|
||||
volatile int *i;
|
||||
volatile LONG *l;
|
||||
} u = { ptr };
|
||||
return InterlockedExchange(u.l, newval);
|
||||
}
|
||||
static __inline void *ExchangePtr(void *volatile*ptr, void *newval)
|
||||
{
|
||||
return InterlockedExchangePointer(ptr, newval);
|
||||
}
|
||||
static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
|
||||
{
|
||||
union {
|
||||
volatile int *i;
|
||||
volatile LONG *l;
|
||||
} u = { ptr };
|
||||
return InterlockedCompareExchange(u.l, newval, oldval) == oldval;
|
||||
}
|
||||
static __inline ALboolean CompExchangePtr(void *volatile*ptr, void *oldval, void *newval)
|
||||
{
|
||||
return InterlockedCompareExchangePointer(ptr, newval, oldval) == oldval;
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
typedef int32_t RefCount;
|
||||
static __inline RefCount IncrementRef(volatile RefCount *ptr)
|
||||
{ return OSAtomicIncrement32Barrier(ptr); }
|
||||
static __inline RefCount DecrementRef(volatile RefCount *ptr)
|
||||
{ return OSAtomicDecrement32Barrier(ptr); }
|
||||
|
||||
static __inline int ExchangeInt(volatile int *ptr, int newval)
|
||||
{
|
||||
/* Really? No regular old atomic swap? */
|
||||
int oldval;
|
||||
do {
|
||||
oldval = *ptr;
|
||||
} while(!OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr));
|
||||
return oldval;
|
||||
}
|
||||
static __inline void *ExchangePtr(void *volatile*ptr, void *newval)
|
||||
{
|
||||
void *oldval;
|
||||
do {
|
||||
oldval = *ptr;
|
||||
} while(!OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr));
|
||||
return oldval;
|
||||
}
|
||||
static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
|
||||
{
|
||||
return OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr);
|
||||
}
|
||||
static __inline ALboolean CompExchangePtr(void *volatile*ptr, void *oldval, void *newval)
|
||||
{
|
||||
return OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr);
|
||||
}
|
||||
|
||||
#else
|
||||
#error "No atomic functions available on this platform!"
|
||||
typedef ALuint RefCount;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
volatile RefCount read_count;
|
||||
volatile RefCount write_count;
|
||||
volatile ALenum read_lock;
|
||||
volatile ALenum read_entry_lock;
|
||||
volatile ALenum write_lock;
|
||||
} RWLock;
|
||||
|
||||
void RWLockInit(RWLock *lock);
|
||||
void ReadLock(RWLock *lock);
|
||||
void ReadUnlock(RWLock *lock);
|
||||
void WriteLock(RWLock *lock);
|
||||
void WriteUnlock(RWLock *lock);
|
||||
|
||||
|
||||
typedef struct UIntMap {
|
||||
struct {
|
||||
ALuint key;
|
||||
ALvoid *value;
|
||||
} *array;
|
||||
ALsizei size;
|
||||
ALsizei maxsize;
|
||||
ALsizei limit;
|
||||
RWLock lock;
|
||||
} UIntMap;
|
||||
extern UIntMap TlsDestructor;
|
||||
|
||||
void InitUIntMap(UIntMap *map, ALsizei limit);
|
||||
void ResetUIntMap(UIntMap *map);
|
||||
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
|
||||
ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);
|
||||
ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
|
||||
|
||||
static __inline void LockUIntMapRead(UIntMap *map)
|
||||
{ ReadLock(&map->lock); }
|
||||
static __inline void UnlockUIntMapRead(UIntMap *map)
|
||||
{ ReadUnlock(&map->lock); }
|
||||
static __inline void LockUIntMapWrite(UIntMap *map)
|
||||
{ WriteLock(&map->lock); }
|
||||
static __inline void UnlockUIntMapWrite(UIntMap *map)
|
||||
{ WriteUnlock(&map->lock); }
|
||||
|
||||
#include "alListener.h"
|
||||
#include "alu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define DEFAULT_OUTPUT_RATE (44100)
|
||||
|
||||
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
|
||||
#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */
|
||||
|
||||
#define LOWPASSFREQREF (5000)
|
||||
|
||||
|
||||
struct Hrtf;
|
||||
|
||||
|
||||
// Find the next power-of-2 for non-power-of-2 numbers.
|
||||
static __inline ALuint NextPowerOf2(ALuint value)
|
||||
{
|
||||
ALuint powerOf2 = 1;
|
||||
|
||||
if(value)
|
||||
{
|
||||
value--;
|
||||
while(value)
|
||||
{
|
||||
value >>= 1;
|
||||
powerOf2 <<= 1;
|
||||
}
|
||||
}
|
||||
return powerOf2;
|
||||
}
|
||||
|
||||
/* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
|
||||
* mode. */
|
||||
static __inline ALint fastf2i(ALfloat f)
|
||||
{
|
||||
ALint i;
|
||||
#if defined(_MSC_VER) && !defined(_WIN64)
|
||||
__asm fld f
|
||||
__asm fistp i
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
__asm__ __volatile__("flds %1\n\t"
|
||||
"fistpl %0\n\t"
|
||||
: "=m" (i)
|
||||
: "m" (f));
|
||||
#else
|
||||
i = (ALint)f;
|
||||
#endif
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
|
||||
* mode. */
|
||||
static __inline ALuint fastf2u(ALfloat f)
|
||||
{ return fastf2i(f); }
|
||||
|
||||
|
||||
enum DevProbe {
|
||||
DEVICE_PROBE,
|
||||
ALL_DEVICE_PROBE,
|
||||
CAPTURE_DEVICE_PROBE
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
ALCenum (*OpenPlayback)(ALCdevice*, const ALCchar*);
|
||||
void (*ClosePlayback)(ALCdevice*);
|
||||
ALCboolean (*ResetPlayback)(ALCdevice*);
|
||||
void (*StopPlayback)(ALCdevice*);
|
||||
|
||||
ALCenum (*OpenCapture)(ALCdevice*, const ALCchar*);
|
||||
void (*CloseCapture)(ALCdevice*);
|
||||
void (*StartCapture)(ALCdevice*);
|
||||
void (*StopCapture)(ALCdevice*);
|
||||
ALCenum (*CaptureSamples)(ALCdevice*, void*, ALCuint);
|
||||
ALCuint (*AvailableSamples)(ALCdevice*);
|
||||
} BackendFuncs;
|
||||
|
||||
struct BackendInfo {
|
||||
const char *name;
|
||||
ALCboolean (*Init)(BackendFuncs*);
|
||||
void (*Deinit)(void);
|
||||
void (*Probe)(enum DevProbe);
|
||||
BackendFuncs Funcs;
|
||||
};
|
||||
|
||||
ALCboolean alc_alsa_init(BackendFuncs *func_list);
|
||||
void alc_alsa_deinit(void);
|
||||
void alc_alsa_probe(enum DevProbe type);
|
||||
ALCboolean alc_oss_init(BackendFuncs *func_list);
|
||||
void alc_oss_deinit(void);
|
||||
void alc_oss_probe(enum DevProbe type);
|
||||
ALCboolean alc_solaris_init(BackendFuncs *func_list);
|
||||
void alc_solaris_deinit(void);
|
||||
void alc_solaris_probe(enum DevProbe type);
|
||||
ALCboolean alc_sndio_init(BackendFuncs *func_list);
|
||||
void alc_sndio_deinit(void);
|
||||
void alc_sndio_probe(enum DevProbe type);
|
||||
ALCboolean alcMMDevApiInit(BackendFuncs *func_list);
|
||||
void alcMMDevApiDeinit(void);
|
||||
void alcMMDevApiProbe(enum DevProbe type);
|
||||
ALCboolean alcDSoundInit(BackendFuncs *func_list);
|
||||
void alcDSoundDeinit(void);
|
||||
void alcDSoundProbe(enum DevProbe type);
|
||||
ALCboolean alcWinMMInit(BackendFuncs *FuncList);
|
||||
void alcWinMMDeinit(void);
|
||||
void alcWinMMProbe(enum DevProbe type);
|
||||
ALCboolean alc_pa_init(BackendFuncs *func_list);
|
||||
void alc_pa_deinit(void);
|
||||
void alc_pa_probe(enum DevProbe type);
|
||||
ALCboolean alc_wave_init(BackendFuncs *func_list);
|
||||
void alc_wave_deinit(void);
|
||||
void alc_wave_probe(enum DevProbe type);
|
||||
ALCboolean alc_pulse_init(BackendFuncs *func_list);
|
||||
void alc_pulse_deinit(void);
|
||||
void alc_pulse_probe(enum DevProbe type);
|
||||
ALCboolean alc_ca_init(BackendFuncs *func_list);
|
||||
void alc_ca_deinit(void);
|
||||
void alc_ca_probe(enum DevProbe type);
|
||||
ALCboolean alc_opensl_init(BackendFuncs *func_list);
|
||||
void alc_opensl_deinit(void);
|
||||
void alc_opensl_probe(enum DevProbe type);
|
||||
ALCboolean alc_android_init(BackendFuncs *func_list);
|
||||
void alc_android_deinit(void);
|
||||
void alc_android_probe(enum DevProbe type);
|
||||
ALCboolean alc_null_init(BackendFuncs *func_list);
|
||||
void alc_null_deinit(void);
|
||||
void alc_null_probe(enum DevProbe type);
|
||||
ALCboolean alc_loopback_init(BackendFuncs *func_list);
|
||||
void alc_loopback_deinit(void);
|
||||
void alc_loopback_probe(enum DevProbe type);
|
||||
|
||||
|
||||
/* Device formats */
|
||||
enum DevFmtType {
|
||||
DevFmtByte = ALC_BYTE,
|
||||
DevFmtUByte = ALC_UNSIGNED_BYTE,
|
||||
DevFmtShort = ALC_SHORT,
|
||||
DevFmtUShort = ALC_UNSIGNED_SHORT,
|
||||
DevFmtFloat = ALC_FLOAT
|
||||
};
|
||||
enum DevFmtChannels {
|
||||
DevFmtMono = ALC_MONO,
|
||||
DevFmtStereo = ALC_STEREO,
|
||||
DevFmtQuad = ALC_QUAD,
|
||||
DevFmtX51 = ALC_5POINT1,
|
||||
DevFmtX61 = ALC_6POINT1,
|
||||
DevFmtX71 = ALC_7POINT1,
|
||||
|
||||
/* Similar to 5.1, except using the side channels instead of back */
|
||||
DevFmtX51Side = 0x80000000 | ALC_5POINT1
|
||||
};
|
||||
|
||||
ALuint BytesFromDevFmt(enum DevFmtType type);
|
||||
ALuint ChannelsFromDevFmt(enum DevFmtChannels chans);
|
||||
static __inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans,
|
||||
enum DevFmtType type)
|
||||
{
|
||||
return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type);
|
||||
}
|
||||
|
||||
|
||||
extern const struct EffectList {
|
||||
const char *name;
|
||||
int type;
|
||||
const char *ename;
|
||||
ALenum val;
|
||||
} EffectList[];
|
||||
|
||||
|
||||
struct ALCdevice_struct
|
||||
{
|
||||
volatile RefCount ref;
|
||||
|
||||
ALCboolean Connected;
|
||||
ALboolean IsCaptureDevice;
|
||||
ALboolean IsLoopbackDevice;
|
||||
|
||||
CRITICAL_SECTION Mutex;
|
||||
|
||||
ALuint Frequency;
|
||||
ALuint UpdateSize;
|
||||
ALuint NumUpdates;
|
||||
enum DevFmtChannels FmtChans;
|
||||
enum DevFmtType FmtType;
|
||||
|
||||
ALCchar *szDeviceName;
|
||||
|
||||
volatile ALCenum LastError;
|
||||
|
||||
// Maximum number of sources that can be created
|
||||
ALuint MaxNoOfSources;
|
||||
// Maximum number of slots that can be created
|
||||
ALuint AuxiliaryEffectSlotMax;
|
||||
|
||||
ALCuint NumMonoSources;
|
||||
ALCuint NumStereoSources;
|
||||
ALuint NumAuxSends;
|
||||
|
||||
// Map of Buffers for this device
|
||||
UIntMap BufferMap;
|
||||
|
||||
// Map of Effects for this device
|
||||
UIntMap EffectMap;
|
||||
|
||||
// Map of Filters for this device
|
||||
UIntMap FilterMap;
|
||||
|
||||
/* HRTF filter tables */
|
||||
const struct Hrtf *Hrtf;
|
||||
|
||||
// Stereo-to-binaural filter
|
||||
struct bs2b *Bs2b;
|
||||
ALCint Bs2bLevel;
|
||||
|
||||
// Device flags
|
||||
ALuint Flags;
|
||||
|
||||
// Dry path buffer mix
|
||||
ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS];
|
||||
|
||||
enum Channel DevChannels[MAXCHANNELS];
|
||||
|
||||
enum Channel Speaker2Chan[MAXCHANNELS];
|
||||
ALfloat PanningLUT[LUT_NUM][MAXCHANNELS];
|
||||
ALuint NumChan;
|
||||
|
||||
ALfloat ClickRemoval[MAXCHANNELS];
|
||||
ALfloat PendingClicks[MAXCHANNELS];
|
||||
|
||||
// Contexts created on this device
|
||||
ALCcontext *volatile ContextList;
|
||||
|
||||
BackendFuncs *Funcs;
|
||||
void *ExtraData; // For the backend's use
|
||||
|
||||
ALCdevice *volatile next;
|
||||
};
|
||||
|
||||
#define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
|
||||
#define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
|
||||
#define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
|
||||
#define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
|
||||
#define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
|
||||
#define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
|
||||
#define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
|
||||
#define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
|
||||
#define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
|
||||
#define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
|
||||
|
||||
// Duplicate stereo sources on the side/rear channels
|
||||
#define DEVICE_DUPLICATE_STEREO (1<<0)
|
||||
// Frequency was requested by the app or config file
|
||||
#define DEVICE_FREQUENCY_REQUEST (1<<1)
|
||||
// Channel configuration was requested by the config file
|
||||
#define DEVICE_CHANNELS_REQUEST (1<<2)
|
||||
|
||||
// Specifies if the device is currently running
|
||||
#define DEVICE_RUNNING (1<<31)
|
||||
|
||||
#define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k)))
|
||||
#define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k)))
|
||||
#define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k)))
|
||||
#define RemoveBuffer(m, k) ((struct ALbuffer*)RemoveUIntMapKey(&(m)->BufferMap, (k)))
|
||||
#define RemoveEffect(m, k) ((struct ALeffect*)RemoveUIntMapKey(&(m)->EffectMap, (k)))
|
||||
#define RemoveFilter(m, k) ((struct ALfilter*)RemoveUIntMapKey(&(m)->FilterMap, (k)))
|
||||
|
||||
|
||||
struct ALCcontext_struct
|
||||
{
|
||||
volatile RefCount ref;
|
||||
|
||||
ALlistener Listener;
|
||||
|
||||
UIntMap SourceMap;
|
||||
UIntMap EffectSlotMap;
|
||||
|
||||
ALenum LastError;
|
||||
|
||||
volatile ALenum UpdateSources;
|
||||
|
||||
volatile enum DistanceModel DistanceModel;
|
||||
volatile ALboolean SourceDistanceModel;
|
||||
|
||||
volatile ALfloat DopplerFactor;
|
||||
volatile ALfloat DopplerVelocity;
|
||||
volatile ALfloat flSpeedOfSound;
|
||||
volatile ALenum DeferUpdates;
|
||||
|
||||
struct ALsource **ActiveSources;
|
||||
ALsizei ActiveSourceCount;
|
||||
ALsizei MaxActiveSources;
|
||||
|
||||
struct ALeffectslot **ActiveEffectSlots;
|
||||
ALsizei ActiveEffectSlotCount;
|
||||
ALsizei MaxActiveEffectSlots;
|
||||
|
||||
ALCdevice *Device;
|
||||
const ALCchar *ExtensionList;
|
||||
|
||||
ALCcontext *volatile next;
|
||||
};
|
||||
|
||||
#define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k)))
|
||||
#define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k)))
|
||||
#define RemoveSource(m, k) ((struct ALsource*)RemoveUIntMapKey(&(m)->SourceMap, (k)))
|
||||
#define RemoveEffectSlot(m, k) ((struct ALeffectslot*)RemoveUIntMapKey(&(m)->EffectSlotMap, (k)))
|
||||
|
||||
ALCcontext *GetContextRef(void);
|
||||
|
||||
void ALCcontext_IncRef(ALCcontext *context);
|
||||
void ALCcontext_DecRef(ALCcontext *context);
|
||||
|
||||
void AppendDeviceList(const ALCchar *name);
|
||||
void AppendAllDeviceList(const ALCchar *name);
|
||||
void AppendCaptureDeviceList(const ALCchar *name);
|
||||
|
||||
ALCvoid LockDevice(ALCdevice *device);
|
||||
ALCvoid UnlockDevice(ALCdevice *device);
|
||||
ALCvoid LockContext(ALCcontext *context);
|
||||
ALCvoid UnlockContext(ALCcontext *context);
|
||||
|
||||
ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
|
||||
ALuint StopThread(ALvoid *thread);
|
||||
|
||||
typedef struct RingBuffer RingBuffer;
|
||||
RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
|
||||
void DestroyRingBuffer(RingBuffer *ring);
|
||||
ALsizei RingBufferSize(RingBuffer *ring);
|
||||
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
|
||||
void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
|
||||
|
||||
void ReadALConfig(void);
|
||||
void FreeALConfig(void);
|
||||
int ConfigValueExists(const char *blockName, const char *keyName);
|
||||
const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
|
||||
int GetConfigValueBool(const char *blockName, const char *keyName, int def);
|
||||
int ConfigValueStr(const char *blockName, const char *keyName, const char **ret);
|
||||
int ConfigValueInt(const char *blockName, const char *keyName, int *ret);
|
||||
int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret);
|
||||
int ConfigValueFloat(const char *blockName, const char *keyName, float *ret);
|
||||
|
||||
void SetRTPriority(void);
|
||||
|
||||
void SetDefaultChannelOrder(ALCdevice *device);
|
||||
void SetDefaultWFXChannelOrder(ALCdevice *device);
|
||||
|
||||
const ALCchar *DevFmtTypeString(enum DevFmtType type);
|
||||
const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans);
|
||||
|
||||
#define HRIR_BITS (5)
|
||||
#define HRIR_LENGTH (1<<HRIR_BITS)
|
||||
#define HRIR_MASK (HRIR_LENGTH-1)
|
||||
void InitHrtf(void);
|
||||
void FreeHrtf(void);
|
||||
const struct Hrtf *GetHrtf(ALCdevice *device);
|
||||
ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]);
|
||||
void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays);
|
||||
ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat delta, ALint counter, ALfloat (*coeffs)[2], ALuint *delays, ALfloat (*coeffStep)[2], ALint *delayStep);
|
||||
|
||||
void al_print(const char *func, const char *fmt, ...) PRINTF_STYLE(2,3);
|
||||
#define AL_PRINT(...) al_print(__FUNCTION__, __VA_ARGS__)
|
||||
|
||||
extern FILE *LogFile;
|
||||
enum LogLevel {
|
||||
NoLog,
|
||||
LogError,
|
||||
LogWarning,
|
||||
LogTrace,
|
||||
LogRef
|
||||
};
|
||||
extern enum LogLevel LogLevel;
|
||||
|
||||
#define TRACEREF(...) do { \
|
||||
if(LogLevel >= LogRef) \
|
||||
AL_PRINT(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define TRACE(...) do { \
|
||||
if(LogLevel >= LogTrace) \
|
||||
AL_PRINT(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define WARN(...) do { \
|
||||
if(LogLevel >= LogWarning) \
|
||||
AL_PRINT(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define ERR(...) do { \
|
||||
if(LogLevel >= LogError) \
|
||||
AL_PRINT(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
|
||||
extern ALint RTPrioLevel;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,142 @@
|
||||
#ifndef _AL_SOURCE_H_
|
||||
#define _AL_SOURCE_H_
|
||||
|
||||
#define MAX_SENDS 4
|
||||
|
||||
#include "alFilter.h"
|
||||
#include "alu.h"
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SRC_HISTORY_BITS (6)
|
||||
#define SRC_HISTORY_LENGTH (1<<SRC_HISTORY_BITS)
|
||||
#define SRC_HISTORY_MASK (SRC_HISTORY_LENGTH-1)
|
||||
|
||||
extern enum Resampler DefaultResampler;
|
||||
|
||||
extern const ALsizei ResamplerPadding[RESAMPLER_MAX];
|
||||
extern const ALsizei ResamplerPrePadding[RESAMPLER_MAX];
|
||||
|
||||
|
||||
typedef struct ALbufferlistitem
|
||||
{
|
||||
struct ALbuffer *buffer;
|
||||
struct ALbufferlistitem *next;
|
||||
struct ALbufferlistitem *prev;
|
||||
} ALbufferlistitem;
|
||||
|
||||
typedef struct ALsource
|
||||
{
|
||||
volatile ALfloat flPitch;
|
||||
volatile ALfloat flGain;
|
||||
volatile ALfloat flOuterGain;
|
||||
volatile ALfloat flMinGain;
|
||||
volatile ALfloat flMaxGain;
|
||||
volatile ALfloat flInnerAngle;
|
||||
volatile ALfloat flOuterAngle;
|
||||
volatile ALfloat flRefDistance;
|
||||
volatile ALfloat flMaxDistance;
|
||||
volatile ALfloat flRollOffFactor;
|
||||
volatile ALfloat vPosition[3];
|
||||
volatile ALfloat vVelocity[3];
|
||||
volatile ALfloat vOrientation[3];
|
||||
volatile ALboolean bHeadRelative;
|
||||
volatile ALboolean bLooping;
|
||||
volatile enum DistanceModel DistanceModel;
|
||||
volatile ALboolean VirtualChannels;
|
||||
|
||||
enum Resampler Resampler;
|
||||
|
||||
volatile ALenum state;
|
||||
ALenum new_state;
|
||||
ALuint position;
|
||||
ALuint position_fraction;
|
||||
|
||||
ALbufferlistitem *queue; // Linked list of buffers in queue
|
||||
ALuint BuffersInQueue; // Number of buffers in queue
|
||||
ALuint BuffersPlayed; // Number of buffers played on this loop
|
||||
|
||||
ALfloat DirectGain;
|
||||
ALfloat DirectGainHF;
|
||||
|
||||
struct {
|
||||
struct ALeffectslot *Slot;
|
||||
ALfloat WetGain;
|
||||
ALfloat WetGainHF;
|
||||
} Send[MAX_SENDS];
|
||||
|
||||
volatile ALboolean DryGainHFAuto;
|
||||
volatile ALboolean WetGainAuto;
|
||||
volatile ALboolean WetGainHFAuto;
|
||||
volatile ALfloat OuterGainHF;
|
||||
|
||||
volatile ALfloat AirAbsorptionFactor;
|
||||
volatile ALfloat RoomRolloffFactor;
|
||||
volatile ALfloat DopplerFactor;
|
||||
|
||||
ALint lOffset;
|
||||
ALint lOffsetType;
|
||||
|
||||
// Source Type (Static, Streaming, or Undetermined)
|
||||
volatile ALint lSourceType;
|
||||
|
||||
ALuint NumChannels;
|
||||
ALuint SampleSize;
|
||||
|
||||
/* HRTF info */
|
||||
ALboolean HrtfMoving;
|
||||
ALuint HrtfCounter;
|
||||
ALfloat HrtfHistory[MAXCHANNELS][SRC_HISTORY_LENGTH];
|
||||
ALfloat HrtfValues[MAXCHANNELS][HRIR_LENGTH][2];
|
||||
ALuint HrtfOffset;
|
||||
|
||||
/* Current target parameters used for mixing */
|
||||
struct {
|
||||
MixerFunc DoMix;
|
||||
|
||||
ALint Step;
|
||||
|
||||
ALfloat HrtfGain;
|
||||
ALfloat HrtfDir[3];
|
||||
ALfloat HrtfCoeffs[MAXCHANNELS][HRIR_LENGTH][2];
|
||||
ALuint HrtfDelay[MAXCHANNELS][2];
|
||||
ALfloat HrtfCoeffStep[HRIR_LENGTH][2];
|
||||
ALint HrtfDelayStep[2];
|
||||
|
||||
/* A mixing matrix. First subscript is the channel number of the input
|
||||
* data (regardless of channel configuration) and the second is the
|
||||
* channel target (eg. FRONT_LEFT) */
|
||||
ALfloat DryGains[MAXCHANNELS][MAXCHANNELS];
|
||||
|
||||
FILTER iirFilter;
|
||||
ALfloat history[MAXCHANNELS*2];
|
||||
|
||||
struct {
|
||||
struct ALeffectslot *Slot;
|
||||
ALfloat WetGain;
|
||||
FILTER iirFilter;
|
||||
ALfloat history[MAXCHANNELS];
|
||||
} Send[MAX_SENDS];
|
||||
} Params;
|
||||
volatile ALenum NeedsUpdate;
|
||||
|
||||
ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
|
||||
|
||||
// Index to itself
|
||||
ALuint source;
|
||||
} ALsource;
|
||||
#define ALsource_Update(s,a) ((s)->Update(s,a))
|
||||
|
||||
ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state);
|
||||
ALboolean ApplyOffset(ALsource *Source);
|
||||
|
||||
ALvoid ReleaseALSources(ALCcontext *Context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _AL_STATE_H_
|
||||
#define _AL_STATE_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef ALTHUNK_H
|
||||
#define ALTHUNK_H
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ThunkInit(void);
|
||||
void ThunkExit(void);
|
||||
ALenum NewThunkEntry(ALuint *index);
|
||||
void FreeThunkEntry(ALuint index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //ALTHUNK_H
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
#ifndef _ALU_H_
|
||||
#define _ALU_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#ifdef HAVE_FLOAT_H
|
||||
#include <float.h>
|
||||
#endif
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define F_PI (3.14159265358979323846f) /* pi */
|
||||
#define F_PI_2 (1.57079632679489661923f) /* pi/2 */
|
||||
|
||||
#ifdef HAVE_POWF
|
||||
#define aluPow(x,y) (powf((x),(y)))
|
||||
#else
|
||||
#define aluPow(x,y) ((ALfloat)pow((double)(x),(double)(y)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SQRTF
|
||||
#define aluSqrt(x) (sqrtf((x)))
|
||||
#else
|
||||
#define aluSqrt(x) ((ALfloat)sqrt((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COSF
|
||||
#define aluCos(x) (cosf((x)))
|
||||
#else
|
||||
#define aluCos(x) ((ALfloat)cos((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SINF
|
||||
#define aluSin(x) (sinf((x)))
|
||||
#else
|
||||
#define aluSin(x) ((ALfloat)sin((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ACOSF
|
||||
#define aluAcos(x) (acosf((x)))
|
||||
#else
|
||||
#define aluAcos(x) ((ALfloat)acos((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ASINF
|
||||
#define aluAsin(x) (asinf((x)))
|
||||
#else
|
||||
#define aluAsin(x) ((ALfloat)asin((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATANF
|
||||
#define aluAtan(x) (atanf((x)))
|
||||
#else
|
||||
#define aluAtan(x) ((ALfloat)atan((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATAN2F
|
||||
#define aluAtan2(x,y) (atan2f((x),(y)))
|
||||
#else
|
||||
#define aluAtan2(x,y) ((ALfloat)atan2((double)(x),(double)(y)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FABSF
|
||||
#define aluFabs(x) (fabsf((x)))
|
||||
#else
|
||||
#define aluFabs(x) ((ALfloat)fabs((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LOG10F
|
||||
#define aluLog10(x) (log10f((x)))
|
||||
#else
|
||||
#define aluLog10(x) ((ALfloat)log10((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FLOORF
|
||||
#define aluFloor(x) (floorf((x)))
|
||||
#else
|
||||
#define aluFloor(x) ((ALfloat)floor((double)(x)))
|
||||
#endif
|
||||
|
||||
#define QUADRANT_NUM 128
|
||||
#define LUT_NUM (4 * QUADRANT_NUM)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ALsource;
|
||||
struct ALbuffer;
|
||||
|
||||
typedef ALvoid (*MixerFunc)(struct ALsource *self, ALCdevice *Device,
|
||||
const ALvoid *RESTRICT data,
|
||||
ALuint *DataPosInt, ALuint *DataPosFrac,
|
||||
ALuint OutPos, ALuint SamplesToDo,
|
||||
ALuint BufferSize);
|
||||
|
||||
enum Resampler {
|
||||
POINT_RESAMPLER = 0,
|
||||
LINEAR_RESAMPLER,
|
||||
CUBIC_RESAMPLER,
|
||||
|
||||
RESAMPLER_MAX,
|
||||
RESAMPLER_MIN = -1,
|
||||
RESAMPLER_DEFAULT = LINEAR_RESAMPLER
|
||||
};
|
||||
|
||||
enum Channel {
|
||||
FRONT_LEFT = 0,
|
||||
FRONT_RIGHT,
|
||||
FRONT_CENTER,
|
||||
LFE,
|
||||
BACK_LEFT,
|
||||
BACK_RIGHT,
|
||||
BACK_CENTER,
|
||||
SIDE_LEFT,
|
||||
SIDE_RIGHT,
|
||||
|
||||
MAXCHANNELS
|
||||
};
|
||||
|
||||
enum DistanceModel {
|
||||
InverseDistanceClamped = AL_INVERSE_DISTANCE_CLAMPED,
|
||||
LinearDistanceClamped = AL_LINEAR_DISTANCE_CLAMPED,
|
||||
ExponentDistanceClamped = AL_EXPONENT_DISTANCE_CLAMPED,
|
||||
InverseDistance = AL_INVERSE_DISTANCE,
|
||||
LinearDistance = AL_LINEAR_DISTANCE,
|
||||
ExponentDistance = AL_EXPONENT_DISTANCE,
|
||||
DisableDistance = AL_NONE
|
||||
};
|
||||
|
||||
#define BUFFERSIZE 4096
|
||||
|
||||
#define FRACTIONBITS (14)
|
||||
#define FRACTIONONE (1<<FRACTIONBITS)
|
||||
#define FRACTIONMASK (FRACTIONONE-1)
|
||||
|
||||
/* Size for temporary stack storage of buffer data. Must be a multiple of the
|
||||
* size of ALfloat, ie, 4. Larger values need more stack, while smaller values
|
||||
* may need more iterations. The value needs to be a sensible size, however, as
|
||||
* it constrains the max stepping value used for mixing.
|
||||
* The mixer requires being able to do two samplings per mixing loop. A 16KB
|
||||
* buffer can hold 512 sample frames for a 7.1 float buffer. With the cubic
|
||||
* resampler (which requires 3 padding sample frames), this limits the maximum
|
||||
* step to about 508. This means that buffer_freq*source_pitch cannot exceed
|
||||
* device_freq*508 for an 8-channel 32-bit buffer. */
|
||||
#ifndef STACK_DATA_SIZE
|
||||
#define STACK_DATA_SIZE 16384
|
||||
#endif
|
||||
|
||||
|
||||
static __inline ALfloat minf(ALfloat a, ALfloat b)
|
||||
{ return ((a > b) ? b : a); }
|
||||
static __inline ALfloat maxf(ALfloat a, ALfloat b)
|
||||
{ return ((a > b) ? a : b); }
|
||||
static __inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max)
|
||||
{ return minf(max, maxf(min, val)); }
|
||||
|
||||
static __inline ALuint minu(ALuint a, ALuint b)
|
||||
{ return ((a > b) ? b : a); }
|
||||
static __inline ALuint maxu(ALuint a, ALuint b)
|
||||
{ return ((a > b) ? a : b); }
|
||||
static __inline ALuint clampu(ALuint val, ALuint min, ALuint max)
|
||||
{ return minu(max, maxu(min, val)); }
|
||||
|
||||
static __inline ALint mini(ALint a, ALint b)
|
||||
{ return ((a > b) ? b : a); }
|
||||
static __inline ALint maxi(ALint a, ALint b)
|
||||
{ return ((a > b) ? a : b); }
|
||||
static __inline ALint clampi(ALint val, ALint min, ALint max)
|
||||
{ return mini(max, maxi(min, val)); }
|
||||
|
||||
static __inline ALint64 mini64(ALint64 a, ALint64 b)
|
||||
{ return ((a > b) ? b : a); }
|
||||
static __inline ALint64 maxi64(ALint64 a, ALint64 b)
|
||||
{ return ((a > b) ? a : b); }
|
||||
static __inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max)
|
||||
{ return mini64(max, maxi64(min, val)); }
|
||||
|
||||
|
||||
static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
|
||||
{
|
||||
return val1 + (val2-val1)*mu;
|
||||
}
|
||||
static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu)
|
||||
{
|
||||
ALfloat mu2 = mu*mu;
|
||||
ALfloat a0 = -0.5f*val0 + 1.5f*val1 + -1.5f*val2 + 0.5f*val3;
|
||||
ALfloat a1 = val0 + -2.5f*val1 + 2.0f*val2 + -0.5f*val3;
|
||||
ALfloat a2 = -0.5f*val0 + 0.5f*val2;
|
||||
ALfloat a3 = val1;
|
||||
|
||||
return a0*mu*mu2 + a1*mu2 + a2*mu + a3;
|
||||
}
|
||||
|
||||
|
||||
static __inline int SetMixerFPUMode(void)
|
||||
{
|
||||
#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
|
||||
fpu_control_t fpuState, newState;
|
||||
_FPU_GETCW(fpuState);
|
||||
newState = fpuState&~(_FPU_EXTENDED|_FPU_DOUBLE|_FPU_SINGLE |
|
||||
_FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO);
|
||||
newState |= _FPU_SINGLE | _FPU_RC_ZERO;
|
||||
_FPU_SETCW(newState);
|
||||
#else
|
||||
int fpuState;
|
||||
#if defined(HAVE__CONTROLFP)
|
||||
fpuState = _controlfp(0, 0);
|
||||
(void)_controlfp(_RC_CHOP|_PC_24, _MCW_RC|_MCW_PC);
|
||||
#elif defined(HAVE_FESETROUND)
|
||||
fpuState = fegetround();
|
||||
fesetround(FE_TOWARDZERO);
|
||||
#endif
|
||||
#endif
|
||||
return fpuState;
|
||||
}
|
||||
|
||||
static __inline void RestoreFPUMode(int state)
|
||||
{
|
||||
#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
|
||||
fpu_control_t fpuState = state;
|
||||
_FPU_SETCW(fpuState);
|
||||
#elif defined(HAVE__CONTROLFP)
|
||||
_controlfp(state, _MCW_RC|_MCW_PC);
|
||||
#elif defined(HAVE_FESETROUND)
|
||||
fesetround(state);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ALvoid aluInitPanning(ALCdevice *Device);
|
||||
ALint aluCart2LUTpos(ALfloat re, ALfloat im);
|
||||
|
||||
ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
|
||||
ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
|
||||
|
||||
MixerFunc SelectMixer(enum Resampler Resampler);
|
||||
MixerFunc SelectHrtfMixer(enum Resampler Resampler);
|
||||
|
||||
ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo);
|
||||
|
||||
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
|
||||
ALvoid aluHandleDisconnect(ALCdevice *device);
|
||||
|
||||
extern ALfloat ConeScale;
|
||||
extern ALfloat ZScale;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Boris Mikhaylov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef BS2B_H
|
||||
#define BS2B_H
|
||||
|
||||
/* Number of crossfeed levels */
|
||||
#define BS2B_CLEVELS 3
|
||||
|
||||
/* Normal crossfeed levels */
|
||||
#define BS2B_HIGH_CLEVEL 3
|
||||
#define BS2B_MIDDLE_CLEVEL 2
|
||||
#define BS2B_LOW_CLEVEL 1
|
||||
|
||||
/* Easy crossfeed levels */
|
||||
#define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS
|
||||
#define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS
|
||||
#define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS
|
||||
|
||||
/* Default crossfeed levels */
|
||||
#define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL
|
||||
/* Default sample rate (Hz) */
|
||||
#define BS2B_DEFAULT_SRATE 44100
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct bs2b {
|
||||
int level; /* Crossfeed level */
|
||||
int srate; /* Sample rate (Hz) */
|
||||
|
||||
/* Lowpass IIR filter coefficients */
|
||||
double a0_lo;
|
||||
double b1_lo;
|
||||
|
||||
/* Highboost IIR filter coefficients */
|
||||
double a0_hi;
|
||||
double a1_hi;
|
||||
double b1_hi;
|
||||
|
||||
/* Global gain against overloading */
|
||||
float gain;
|
||||
|
||||
/* Buffer of last filtered sample.
|
||||
* [0] - first channel, [1] - second channel
|
||||
*/
|
||||
struct t_last_sample {
|
||||
double asis[2];
|
||||
double lo[2];
|
||||
double hi[2];
|
||||
} last_sample;
|
||||
};
|
||||
|
||||
/* Clear buffers and set new coefficients with new crossfeed level value.
|
||||
* level - crossfeed level of *LEVEL values.
|
||||
*/
|
||||
void bs2b_set_level(struct bs2b *bs2b, int level);
|
||||
|
||||
/* Return current crossfeed level value */
|
||||
int bs2b_get_level(struct bs2b *bs2b);
|
||||
|
||||
/* Clear buffers and set new coefficients with new sample rate value.
|
||||
* srate - sample rate by Hz.
|
||||
*/
|
||||
void bs2b_set_srate(struct bs2b *bs2b, int srate);
|
||||
|
||||
/* Return current sample rate value */
|
||||
int bs2b_get_srate(struct bs2b *bs2b);
|
||||
|
||||
/* Clear buffer */
|
||||
void bs2b_clear(struct bs2b *bs2b);
|
||||
|
||||
/* Return 1 if buffer is clear */
|
||||
int bs2b_is_clear(struct bs2b *bs2b);
|
||||
|
||||
/* Crossfeeds one stereo sample that are pointed by sample.
|
||||
* [0] - first channel, [1] - second channel.
|
||||
* Returns crossfided samle by sample pointer.
|
||||
*/
|
||||
|
||||
/* sample poits to floats */
|
||||
void bs2b_cross_feed(struct bs2b *bs2b, float *sample);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* BS2B_H */
|
||||
Reference in New Issue
Block a user