added dependencies and build files (loosely inspired by Sebastian Dorda's love-native-android)

This commit is contained in:
Martin Felis
2013-12-05 17:58:37 +01:00
parent 9604528a96
commit 95a086a47f
3700 changed files with 1691119 additions and 0 deletions
@@ -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 */
@@ -0,0 +1,618 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2007 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "config.h"
#include <stdlib.h>
#include <math.h>
#include "AL/al.h"
#include "AL/alc.h"
#include "alMain.h"
#include "alAuxEffectSlot.h"
#include "alThunk.h"
#include "alError.h"
#include "alSource.h"
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect);
static ALenum ResizeEffectSlotArray(ALCcontext *Context, ALsizei count);
static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *val);
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
ALCcontext *Context;
ALCdevice *Device;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
alSetError(Context, AL_INVALID_VALUE);
else
{
ALenum err;
ALsizei i, j;
err = ResizeEffectSlotArray(Context, n);
if(err != AL_NO_ERROR)
{
alSetError(Context, err);
n = 0;
}
for(i = 0;i < n;i++)
{
ALeffectslot *slot = calloc(1, sizeof(ALeffectslot));
if(!slot || !(slot->EffectState=NoneCreate()))
{
free(slot);
// We must have run out or memory
alSetError(Context, AL_OUT_OF_MEMORY);
alDeleteAuxiliaryEffectSlots(i, effectslots);
break;
}
slot->Gain = 1.0;
slot->AuxSendAuto = AL_TRUE;
slot->NeedsUpdate = AL_FALSE;
for(j = 0;j < BUFFERSIZE;j++)
slot->WetBuffer[j] = 0.0f;
for(j = 0;j < 1;j++)
{
slot->ClickRemoval[j] = 0.0f;
slot->PendingClicks[j] = 0.0f;
}
slot->ref = 0;
LockContext(Context);
err = ResizeEffectSlotArray(Context, 1);
if(err == AL_NO_ERROR)
Context->ActiveEffectSlots[Context->ActiveEffectSlotCount++] = slot;
UnlockContext(Context);
if(err == AL_NO_ERROR)
err = NewThunkEntry(&slot->effectslot);
if(err == AL_NO_ERROR)
err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot);
if(err != AL_NO_ERROR)
{
RemoveEffectSlotArray(Context, slot);
FreeThunkEntry(slot->effectslot);
ALeffectState_Destroy(slot->EffectState);
free(slot);
alSetError(Context, err);
alDeleteAuxiliaryEffectSlots(i, effectslots);
break;
}
effectslots[i] = slot->effectslot;
}
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots)
{
ALCcontext *Context;
ALeffectslot *EffectSlot;
ALsizei i;
Context = GetContextRef();
if(!Context) return;
if(n < 0)
alSetError(Context, AL_INVALID_VALUE);
else
{
// Check that all effectslots are valid
for(i = 0;i < n;i++)
{
if((EffectSlot=LookupEffectSlot(Context, effectslots[i])) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
n = 0;
break;
}
else if(EffectSlot->ref != 0)
{
alSetError(Context, AL_INVALID_OPERATION);
n = 0;
break;
}
}
// All effectslots are valid
for(i = 0;i < n;i++)
{
// Recheck that the effectslot is valid, because there could be duplicated names
if((EffectSlot=RemoveEffectSlot(Context, effectslots[i])) == NULL)
continue;
FreeThunkEntry(EffectSlot->effectslot);
RemoveEffectSlotArray(Context, EffectSlot);
ALeffectState_Destroy(EffectSlot->EffectState);
memset(EffectSlot, 0, sizeof(ALeffectslot));
free(EffectSlot);
}
}
ALCcontext_DecRef(Context);
}
AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
{
ALCcontext *Context;
ALboolean result;
Context = GetContextRef();
if(!Context) return AL_FALSE;
result = (LookupEffectSlot(Context, effectslot) ? AL_TRUE : AL_FALSE);
ALCcontext_DecRef(Context);
return result;
}
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue)
{
ALCdevice *Device;
ALCcontext *Context;
ALeffectslot *EffectSlot;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
case AL_EFFECTSLOT_EFFECT: {
ALeffect *effect = NULL;
if(iValue == 0 ||
(effect=LookupEffect(Device, iValue)) != NULL)
{
InitializeEffect(Context, EffectSlot, effect);
Context->UpdateSources = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
} break;
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
if(iValue == AL_TRUE || iValue == AL_FALSE)
{
EffectSlot->AuxSendAuto = iValue;
Context->UpdateSources = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues)
{
ALCcontext *Context;
switch(param)
{
case AL_EFFECTSLOT_EFFECT:
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
alAuxiliaryEffectSloti(effectslot, param, piValues[0]);
return;
}
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue)
{
ALCcontext *Context;
ALeffectslot *EffectSlot;
Context = GetContextRef();
if(!Context) return;
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
case AL_EFFECTSLOT_GAIN:
if(flValue >= 0.0f && flValue <= 1.0f)
{
EffectSlot->Gain = flValue;
EffectSlot->NeedsUpdate = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues)
{
ALCcontext *Context;
switch(param)
{
case AL_EFFECTSLOT_GAIN:
alAuxiliaryEffectSlotf(effectslot, param, pflValues[0]);
return;
}
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue)
{
ALCcontext *Context;
ALeffectslot *EffectSlot;
Context = GetContextRef();
if(!Context) return;
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
case AL_EFFECTSLOT_EFFECT:
*piValue = EffectSlot->effect.effect;
break;
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
*piValue = EffectSlot->AuxSendAuto;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues)
{
ALCcontext *Context;
switch(param)
{
case AL_EFFECTSLOT_EFFECT:
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
alGetAuxiliaryEffectSloti(effectslot, param, piValues);
return;
}
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue)
{
ALCcontext *Context;
ALeffectslot *EffectSlot;
Context = GetContextRef();
if(!Context) return;
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
case AL_EFFECTSLOT_GAIN:
*pflValue = EffectSlot->Gain;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues)
{
ALCcontext *Context;
switch(param)
{
case AL_EFFECTSLOT_GAIN:
alGetAuxiliaryEffectSlotf(effectslot, param, pflValues);
return;
}
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
static ALvoid NoneDestroy(ALeffectState *State)
{ free(State); }
static ALboolean NoneDeviceUpdate(ALeffectState *State, ALCdevice *Device)
{
return AL_TRUE;
(void)State;
(void)Device;
}
static ALvoid NoneUpdate(ALeffectState *State, ALCcontext *Context, const ALeffectslot *Slot)
{
(void)State;
(void)Context;
(void)Slot;
}
static ALvoid NoneProcess(ALeffectState *State, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])
{
(void)State;
(void)SamplesToDo;
(void)SamplesIn;
(void)SamplesOut;
}
ALeffectState *NoneCreate(void)
{
ALeffectState *state;
state = calloc(1, sizeof(*state));
if(!state)
return NULL;
state->Destroy = NoneDestroy;
state->DeviceUpdate = NoneDeviceUpdate;
state->Update = NoneUpdate;
state->Process = NoneProcess;
return state;
}
static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *slot)
{
ALeffectslot **slotlist, **slotlistend;
LockContext(Context);
slotlist = Context->ActiveEffectSlots;
slotlistend = slotlist + Context->ActiveEffectSlotCount;
while(slotlist != slotlistend)
{
if(*slotlist == slot)
{
*slotlist = *(--slotlistend);
Context->ActiveEffectSlotCount--;
break;
}
slotlist++;
}
UnlockContext(Context);
}
static ALenum ResizeEffectSlotArray(ALCcontext *Context, ALsizei count)
{
ALsizei newcount;
void *temp;
if(count <= Context->MaxActiveEffectSlots-Context->ActiveEffectSlotCount)
return AL_NO_ERROR;
newcount = Context->MaxActiveEffectSlots ?
(Context->MaxActiveEffectSlots<<1) : 1;
if(newcount <= Context->MaxActiveEffectSlots ||
!(temp=realloc(Context->ActiveEffectSlots, newcount *
sizeof(*Context->ActiveEffectSlots))))
return AL_OUT_OF_MEMORY;
Context->ActiveEffectSlots = temp;
Context->MaxActiveEffectSlots = newcount;
return AL_NO_ERROR;
}
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect)
{
ALenum newtype = (effect ? effect->type : AL_EFFECT_NULL);
ALeffectState *State = NULL;
ALenum err = AL_NO_ERROR;
LockContext(Context);
if(newtype == AL_EFFECT_NULL && EffectSlot->effect.type != AL_EFFECT_NULL)
{
State = NoneCreate();
if(!State) err = AL_OUT_OF_MEMORY;
}
else if(newtype == AL_EFFECT_EAXREVERB || newtype == AL_EFFECT_REVERB)
{
if(EffectSlot->effect.type != AL_EFFECT_EAXREVERB && EffectSlot->effect.type != AL_EFFECT_REVERB)
{
State = ReverbCreate();
if(!State) err = AL_OUT_OF_MEMORY;
}
}
else if(newtype == AL_EFFECT_ECHO && EffectSlot->effect.type != AL_EFFECT_ECHO)
{
State = EchoCreate();
if(!State) err = AL_OUT_OF_MEMORY;
}
else if(newtype == AL_EFFECT_RING_MODULATOR && EffectSlot->effect.type != AL_EFFECT_RING_MODULATOR)
{
State = ModulatorCreate();
if(!State) err = AL_OUT_OF_MEMORY;
}
else if(newtype == AL_EFFECT_DEDICATED_DIALOGUE || newtype == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
{
if(EffectSlot->effect.type != AL_EFFECT_DEDICATED_DIALOGUE && EffectSlot->effect.type != AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
{
State = DedicatedCreate();
if(!State) err = AL_OUT_OF_MEMORY;
}
}
if(err != AL_NO_ERROR)
{
UnlockContext(Context);
alSetError(Context, err);
return;
}
if(State)
{
int oldMode;
oldMode = SetMixerFPUMode();
if(ALeffectState_DeviceUpdate(State, Context->Device) == AL_FALSE)
{
UnlockContext(Context);
ALeffectState_Destroy(State);
alSetError(Context, AL_OUT_OF_MEMORY);
return;
}
State = ExchangePtr((void**)&EffectSlot->EffectState, State);
if(!effect)
memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect));
else
memcpy(&EffectSlot->effect, effect, sizeof(*effect));
/* FIXME: This should be done asynchronously, but since the EffectState
* object was changed, it needs an update before its Process method can
* be called. */
EffectSlot->NeedsUpdate = AL_FALSE;
ALeffectState_Update(EffectSlot->EffectState, Context, EffectSlot);
UnlockContext(Context);
RestoreFPUMode(oldMode);
ALeffectState_Destroy(State);
State = NULL;
}
else
{
if(!effect)
memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect));
else
memcpy(&EffectSlot->effect, effect, sizeof(*effect));
UnlockContext(Context);
EffectSlot->NeedsUpdate = AL_TRUE;
}
}
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context)
{
ALsizei pos;
for(pos = 0;pos < Context->EffectSlotMap.size;pos++)
{
ALeffectslot *temp = Context->EffectSlotMap.array[pos].value;
Context->EffectSlotMap.array[pos].value = NULL;
// Release effectslot structure
ALeffectState_Destroy(temp->EffectState);
FreeThunkEntry(temp->effectslot);
memset(temp, 0, sizeof(ALeffectslot));
free(temp);
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,59 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2000 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "config.h"
#include <signal.h>
#include "alMain.h"
#include "AL/alc.h"
#include "alError.h"
ALboolean TrapALError = AL_FALSE;
AL_API ALenum AL_APIENTRY alGetError(void)
{
ALCcontext *Context;
ALenum errorCode;
Context = GetContextRef();
if(!Context) return AL_INVALID_OPERATION;
errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR);
ALCcontext_DecRef(Context);
return errorCode;
}
ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
{
if(TrapALError)
{
#ifdef _WIN32
/* DebugBreak will cause an exception if there is no debugger */
if(IsDebuggerPresent())
DebugBreak();
#elif defined(SIGTRAP)
raise(SIGTRAP);
#endif
}
CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode);
}
@@ -0,0 +1,405 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2007 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "alError.h"
#include "alMain.h"
#include "alFilter.h"
#include "alEffect.h"
#include "alAuxEffectSlot.h"
#include "alSource.h"
#include "alBuffer.h"
#include "AL/al.h"
#include "AL/alc.h"
typedef struct ALenums {
const ALchar *enumName;
ALenum value;
} ALenums;
static const ALenums enumeration[] = {
// Types
{ "AL_INVALID", AL_INVALID },
{ "AL_NONE", AL_NONE },
{ "AL_FALSE", AL_FALSE },
{ "AL_TRUE", AL_TRUE },
// Source and Listener Properties
{ "AL_SOURCE_RELATIVE", AL_SOURCE_RELATIVE },
{ "AL_CONE_INNER_ANGLE", AL_CONE_INNER_ANGLE },
{ "AL_CONE_OUTER_ANGLE", AL_CONE_OUTER_ANGLE },
{ "AL_PITCH", AL_PITCH },
{ "AL_POSITION", AL_POSITION },
{ "AL_DIRECTION", AL_DIRECTION },
{ "AL_VELOCITY", AL_VELOCITY },
{ "AL_LOOPING", AL_LOOPING },
{ "AL_BUFFER", AL_BUFFER },
{ "AL_GAIN", AL_GAIN },
{ "AL_MIN_GAIN", AL_MIN_GAIN },
{ "AL_MAX_GAIN", AL_MAX_GAIN },
{ "AL_ORIENTATION", AL_ORIENTATION },
{ "AL_REFERENCE_DISTANCE", AL_REFERENCE_DISTANCE },
{ "AL_ROLLOFF_FACTOR", AL_ROLLOFF_FACTOR },
{ "AL_CONE_OUTER_GAIN", AL_CONE_OUTER_GAIN },
{ "AL_MAX_DISTANCE", AL_MAX_DISTANCE },
{ "AL_SEC_OFFSET", AL_SEC_OFFSET },
{ "AL_SAMPLE_OFFSET", AL_SAMPLE_OFFSET },
{ "AL_SAMPLE_RW_OFFSETS_SOFT", AL_SAMPLE_RW_OFFSETS_SOFT },
{ "AL_BYTE_OFFSET", AL_BYTE_OFFSET },
{ "AL_BYTE_RW_OFFSETS_SOFT", AL_BYTE_RW_OFFSETS_SOFT },
{ "AL_SOURCE_TYPE", AL_SOURCE_TYPE },
{ "AL_STATIC", AL_STATIC },
{ "AL_STREAMING", AL_STREAMING },
{ "AL_UNDETERMINED", AL_UNDETERMINED },
{ "AL_METERS_PER_UNIT", AL_METERS_PER_UNIT },
{ "AL_VIRTUAL_CHANNELS_SOFT", AL_VIRTUAL_CHANNELS_SOFT },
// Source EFX Properties
{ "AL_DIRECT_FILTER", AL_DIRECT_FILTER },
{ "AL_AUXILIARY_SEND_FILTER", AL_AUXILIARY_SEND_FILTER },
{ "AL_AIR_ABSORPTION_FACTOR", AL_AIR_ABSORPTION_FACTOR },
{ "AL_ROOM_ROLLOFF_FACTOR", AL_ROOM_ROLLOFF_FACTOR },
{ "AL_CONE_OUTER_GAINHF", AL_CONE_OUTER_GAINHF },
{ "AL_DIRECT_FILTER_GAINHF_AUTO", AL_DIRECT_FILTER_GAINHF_AUTO },
{ "AL_AUXILIARY_SEND_FILTER_GAIN_AUTO", AL_AUXILIARY_SEND_FILTER_GAIN_AUTO },
{ "AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO", AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO},
// Source State information
{ "AL_SOURCE_STATE", AL_SOURCE_STATE },
{ "AL_INITIAL", AL_INITIAL },
{ "AL_PLAYING", AL_PLAYING },
{ "AL_PAUSED", AL_PAUSED },
{ "AL_STOPPED", AL_STOPPED },
// Queue information
{ "AL_BUFFERS_QUEUED", AL_BUFFERS_QUEUED },
{ "AL_BUFFERS_PROCESSED", AL_BUFFERS_PROCESSED },
// Buffer Formats
{ "AL_FORMAT_MONO8", AL_FORMAT_MONO8 },
{ "AL_FORMAT_MONO16", AL_FORMAT_MONO16 },
{ "AL_FORMAT_MONO_FLOAT32", AL_FORMAT_MONO_FLOAT32 },
{ "AL_FORMAT_MONO_DOUBLE_EXT", AL_FORMAT_MONO_DOUBLE_EXT },
{ "AL_FORMAT_STEREO8", AL_FORMAT_STEREO8 },
{ "AL_FORMAT_STEREO16", AL_FORMAT_STEREO16 },
{ "AL_FORMAT_STEREO_FLOAT32", AL_FORMAT_STEREO_FLOAT32 },
{ "AL_FORMAT_STEREO_DOUBLE_EXT", AL_FORMAT_STEREO_DOUBLE_EXT },
{ "AL_FORMAT_MONO_IMA4", AL_FORMAT_MONO_IMA4 },
{ "AL_FORMAT_STEREO_IMA4", AL_FORMAT_STEREO_IMA4 },
{ "AL_FORMAT_QUAD8_LOKI", AL_FORMAT_QUAD8_LOKI },
{ "AL_FORMAT_QUAD16_LOKI", AL_FORMAT_QUAD16_LOKI },
{ "AL_FORMAT_QUAD8", AL_FORMAT_QUAD8 },
{ "AL_FORMAT_QUAD16", AL_FORMAT_QUAD16 },
{ "AL_FORMAT_QUAD32", AL_FORMAT_QUAD32 },
{ "AL_FORMAT_51CHN8", AL_FORMAT_51CHN8 },
{ "AL_FORMAT_51CHN16", AL_FORMAT_51CHN16 },
{ "AL_FORMAT_51CHN32", AL_FORMAT_51CHN32 },
{ "AL_FORMAT_61CHN8", AL_FORMAT_61CHN8 },
{ "AL_FORMAT_61CHN16", AL_FORMAT_61CHN16 },
{ "AL_FORMAT_61CHN32", AL_FORMAT_61CHN32 },
{ "AL_FORMAT_71CHN8", AL_FORMAT_71CHN8 },
{ "AL_FORMAT_71CHN16", AL_FORMAT_71CHN16 },
{ "AL_FORMAT_71CHN32", AL_FORMAT_71CHN32 },
{ "AL_FORMAT_REAR8", AL_FORMAT_REAR8 },
{ "AL_FORMAT_REAR16", AL_FORMAT_REAR16 },
{ "AL_FORMAT_REAR32", AL_FORMAT_REAR32 },
{ "AL_FORMAT_MONO_MULAW", AL_FORMAT_MONO_MULAW },
{ "AL_FORMAT_MONO_MULAW_EXT", AL_FORMAT_MONO_MULAW_EXT },
{ "AL_FORMAT_STEREO_MULAW", AL_FORMAT_STEREO_MULAW },
{ "AL_FORMAT_STEREO_MULAW_EXT", AL_FORMAT_STEREO_MULAW_EXT },
{ "AL_FORMAT_QUAD_MULAW", AL_FORMAT_QUAD_MULAW },
{ "AL_FORMAT_51CHN_MULAW", AL_FORMAT_51CHN_MULAW },
{ "AL_FORMAT_61CHN_MULAW", AL_FORMAT_61CHN_MULAW },
{ "AL_FORMAT_71CHN_MULAW", AL_FORMAT_71CHN_MULAW },
{ "AL_FORMAT_REAR_MULAW", AL_FORMAT_REAR_MULAW },
{ "AL_FORMAT_MONO_ALAW_EXT", AL_FORMAT_MONO_ALAW_EXT },
{ "AL_FORMAT_STEREO_ALAW_EXT", AL_FORMAT_STEREO_ALAW_EXT },
// Internal Buffer Formats
{ "AL_MONO8", AL_MONO8 },
{ "AL_MONO16", AL_MONO16 },
{ "AL_MONO32F", AL_MONO32F },
{ "AL_STEREO8", AL_STEREO8 },
{ "AL_STEREO16", AL_STEREO16 },
{ "AL_STEREO32F", AL_STEREO32F },
{ "AL_QUAD8", AL_QUAD8 },
{ "AL_QUAD16", AL_QUAD16 },
{ "AL_QUAD32F", AL_QUAD32F },
{ "AL_REAR8", AL_REAR8 },
{ "AL_REAR16", AL_REAR16 },
{ "AL_REAR32F", AL_REAR32F },
{ "AL_5POINT1_8", AL_5POINT1_8 },
{ "AL_5POINT1_16", AL_5POINT1_16 },
{ "AL_5POINT1_32F", AL_5POINT1_32F },
{ "AL_6POINT1_8", AL_6POINT1_8 },
{ "AL_6POINT1_16", AL_6POINT1_16 },
{ "AL_6POINT1_32F", AL_6POINT1_32F },
{ "AL_7POINT1_8", AL_7POINT1_8 },
{ "AL_7POINT1_16", AL_7POINT1_16 },
{ "AL_7POINT1_32F", AL_7POINT1_32F },
// Buffer Channel Configurations
{ "AL_MONO", AL_MONO },
{ "AL_STEREO", AL_STEREO },
{ "AL_QUAD", AL_QUAD },
{ "AL_REAR", AL_REAR },
{ "AL_5POINT1", AL_5POINT1 },
{ "AL_6POINT1", AL_6POINT1 },
{ "AL_7POINT1", AL_7POINT1 },
// Buffer Sample Types
{ "AL_BYTE", AL_BYTE },
{ "AL_UNSIGNED_BYTE", AL_UNSIGNED_BYTE },
{ "AL_SHORT", AL_SHORT },
{ "AL_UNSIGNED_SHORT", AL_UNSIGNED_SHORT },
{ "AL_INT", AL_INT },
{ "AL_UNSIGNED_INT", AL_UNSIGNED_INT },
{ "AL_FLOAT", AL_FLOAT },
{ "AL_DOUBLE", AL_DOUBLE },
{ "AL_MULAW", AL_MULAW },
{ "AL_ALAW", AL_ALAW },
{ "AL_IMA4", AL_IMA4 },
{ "AL_BYTE3", AL_BYTE3 },
{ "AL_UNSIGNED_BYTE3", AL_UNSIGNED_BYTE3 },
// Buffer attributes
{ "AL_FREQUENCY", AL_FREQUENCY },
{ "AL_BITS", AL_BITS },
{ "AL_CHANNELS", AL_CHANNELS },
{ "AL_SIZE", AL_SIZE },
{ "AL_INTERNAL_FORMAT", AL_INTERNAL_FORMAT },
{ "AL_BYTE_LENGTH", AL_BYTE_LENGTH },
{ "AL_SAMPLE_LENGTH", AL_SAMPLE_LENGTH },
{ "AL_SEC_LENGTH", AL_SEC_LENGTH },
// Buffer States (not supported yet)
{ "AL_UNUSED", AL_UNUSED },
{ "AL_PENDING", AL_PENDING },
{ "AL_PROCESSED", AL_PROCESSED },
// AL Error Messages
{ "AL_NO_ERROR", AL_NO_ERROR },
{ "AL_INVALID_NAME", AL_INVALID_NAME },
{ "AL_INVALID_ENUM", AL_INVALID_ENUM },
{ "AL_INVALID_VALUE", AL_INVALID_VALUE },
{ "AL_INVALID_OPERATION", AL_INVALID_OPERATION },
{ "AL_OUT_OF_MEMORY", AL_OUT_OF_MEMORY },
// Context strings
{ "AL_VENDOR", AL_VENDOR },
{ "AL_VERSION", AL_VERSION },
{ "AL_RENDERER", AL_RENDERER },
{ "AL_EXTENSIONS", AL_EXTENSIONS },
// Global states
{ "AL_DOPPLER_FACTOR", AL_DOPPLER_FACTOR },
{ "AL_DOPPLER_VELOCITY", AL_DOPPLER_VELOCITY },
{ "AL_DISTANCE_MODEL", AL_DISTANCE_MODEL },
{ "AL_SPEED_OF_SOUND", AL_SPEED_OF_SOUND },
{ "AL_SOURCE_DISTANCE_MODEL", AL_SOURCE_DISTANCE_MODEL },
{ "AL_DEFERRED_UPDATES_SOFT", AL_DEFERRED_UPDATES_SOFT },
// Distance Models
{ "AL_INVERSE_DISTANCE", AL_INVERSE_DISTANCE },
{ "AL_INVERSE_DISTANCE_CLAMPED", AL_INVERSE_DISTANCE_CLAMPED },
{ "AL_LINEAR_DISTANCE", AL_LINEAR_DISTANCE },
{ "AL_LINEAR_DISTANCE_CLAMPED", AL_LINEAR_DISTANCE_CLAMPED },
{ "AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE },
{ "AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED },
// Filter types
{ "AL_FILTER_TYPE", AL_FILTER_TYPE },
{ "AL_FILTER_NULL", AL_FILTER_NULL },
{ "AL_FILTER_LOWPASS", AL_FILTER_LOWPASS },
#if 0
{ "AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS },
{ "AL_FILTER_BANDPASS", AL_FILTER_BANDPASS },
#endif
// Filter params
{ "AL_LOWPASS_GAIN", AL_LOWPASS_GAIN },
{ "AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF },
// Effect types
{ "AL_EFFECT_TYPE", AL_EFFECT_TYPE },
{ "AL_EFFECT_NULL", AL_EFFECT_NULL },
{ "AL_EFFECT_REVERB", AL_EFFECT_REVERB },
{ "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB },
#if 0
{ "AL_EFFECT_CHORUS", AL_EFFECT_CHORUS },
{ "AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION },
#endif
{ "AL_EFFECT_ECHO", AL_EFFECT_ECHO },
#if 0
{ "AL_EFFECT_FLANGER", AL_EFFECT_FLANGER },
{ "AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER },
{ "AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER },
{ "AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER },
#endif
{ "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
#if 0
{ "AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH },
{ "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR },
{ "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
#endif
{ "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT",AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT},
{ "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE },
// Reverb params
{ "AL_REVERB_DENSITY", AL_REVERB_DENSITY },
{ "AL_REVERB_DIFFUSION", AL_REVERB_DIFFUSION },
{ "AL_REVERB_GAIN", AL_REVERB_GAIN },
{ "AL_REVERB_GAINHF", AL_REVERB_GAINHF },
{ "AL_REVERB_DECAY_TIME", AL_REVERB_DECAY_TIME },
{ "AL_REVERB_DECAY_HFRATIO", AL_REVERB_DECAY_HFRATIO },
{ "AL_REVERB_REFLECTIONS_GAIN", AL_REVERB_REFLECTIONS_GAIN },
{ "AL_REVERB_REFLECTIONS_DELAY", AL_REVERB_REFLECTIONS_DELAY },
{ "AL_REVERB_LATE_REVERB_GAIN", AL_REVERB_LATE_REVERB_GAIN },
{ "AL_REVERB_LATE_REVERB_DELAY", AL_REVERB_LATE_REVERB_DELAY },
{ "AL_REVERB_AIR_ABSORPTION_GAINHF", AL_REVERB_AIR_ABSORPTION_GAINHF },
{ "AL_REVERB_ROOM_ROLLOFF_FACTOR", AL_REVERB_ROOM_ROLLOFF_FACTOR },
{ "AL_REVERB_DECAY_HFLIMIT", AL_REVERB_DECAY_HFLIMIT },
// EAX Reverb params
{ "AL_EAXREVERB_DENSITY", AL_EAXREVERB_DENSITY },
{ "AL_EAXREVERB_DIFFUSION", AL_EAXREVERB_DIFFUSION },
{ "AL_EAXREVERB_GAIN", AL_EAXREVERB_GAIN },
{ "AL_EAXREVERB_GAINHF", AL_EAXREVERB_GAINHF },
{ "AL_EAXREVERB_GAINLF", AL_EAXREVERB_GAINLF },
{ "AL_EAXREVERB_DECAY_TIME", AL_EAXREVERB_DECAY_TIME },
{ "AL_EAXREVERB_DECAY_HFRATIO", AL_EAXREVERB_DECAY_HFRATIO },
{ "AL_EAXREVERB_DECAY_LFRATIO", AL_EAXREVERB_DECAY_LFRATIO },
{ "AL_EAXREVERB_REFLECTIONS_GAIN", AL_EAXREVERB_REFLECTIONS_GAIN },
{ "AL_EAXREVERB_REFLECTIONS_DELAY", AL_EAXREVERB_REFLECTIONS_DELAY },
{ "AL_EAXREVERB_REFLECTIONS_PAN", AL_EAXREVERB_REFLECTIONS_PAN },
{ "AL_EAXREVERB_LATE_REVERB_GAIN", AL_EAXREVERB_LATE_REVERB_GAIN },
{ "AL_EAXREVERB_LATE_REVERB_DELAY", AL_EAXREVERB_LATE_REVERB_DELAY },
{ "AL_EAXREVERB_LATE_REVERB_PAN", AL_EAXREVERB_LATE_REVERB_PAN },
{ "AL_EAXREVERB_ECHO_TIME", AL_EAXREVERB_ECHO_TIME },
{ "AL_EAXREVERB_ECHO_DEPTH", AL_EAXREVERB_ECHO_DEPTH },
{ "AL_EAXREVERB_MODULATION_TIME", AL_EAXREVERB_MODULATION_TIME },
{ "AL_EAXREVERB_MODULATION_DEPTH", AL_EAXREVERB_MODULATION_DEPTH },
{ "AL_EAXREVERB_AIR_ABSORPTION_GAINHF", AL_EAXREVERB_AIR_ABSORPTION_GAINHF },
{ "AL_EAXREVERB_HFREFERENCE", AL_EAXREVERB_HFREFERENCE },
{ "AL_EAXREVERB_LFREFERENCE", AL_EAXREVERB_LFREFERENCE },
{ "AL_EAXREVERB_ROOM_ROLLOFF_FACTOR", AL_EAXREVERB_ROOM_ROLLOFF_FACTOR },
{ "AL_EAXREVERB_DECAY_HFLIMIT", AL_EAXREVERB_DECAY_HFLIMIT },
// Echo params
{ "AL_ECHO_DELAY", AL_ECHO_DELAY },
{ "AL_ECHO_LRDELAY", AL_ECHO_LRDELAY },
{ "AL_ECHO_DAMPING", AL_ECHO_DAMPING },
{ "AL_ECHO_FEEDBACK", AL_ECHO_FEEDBACK },
{ "AL_ECHO_SPREAD", AL_ECHO_SPREAD },
// Ring Modulator params
{ "AL_RING_MODULATOR_FREQUENCY", AL_RING_MODULATOR_FREQUENCY },
{ "AL_RING_MODULATOR_HIGHPASS_CUTOFF", AL_RING_MODULATOR_HIGHPASS_CUTOFF },
{ "AL_RING_MODULATOR_WAVEFORM", AL_RING_MODULATOR_WAVEFORM },
// Dedicated Dialogue/LFE params
{ "AL_DEDICATED_GAIN", AL_DEDICATED_GAIN },
// Default
{ NULL, (ALenum)0 }
};
const struct EffectList EffectList[] = {
{ "eaxreverb", EAXREVERB, "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB },
{ "reverb", REVERB, "AL_EFFECT_REVERB", AL_EFFECT_REVERB },
{ "echo", ECHO, "AL_EFFECT_ECHO", AL_EFFECT_ECHO },
{ "modulator", MODULATOR, "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
{ "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT", AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT },
{ "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE },
{ NULL, 0, NULL, (ALenum)0 }
};
AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName)
{
ALboolean bIsSupported = AL_FALSE;
ALCcontext *Context;
const char *ptr;
size_t len;
Context = GetContextRef();
if(!Context) return AL_FALSE;
if(!extName)
alSetError(Context, AL_INVALID_VALUE);
else
{
len = strlen(extName);
ptr = Context->ExtensionList;
while(ptr && *ptr)
{
if(strncasecmp(ptr, extName, len) == 0 &&
(ptr[len] == '\0' || isspace(ptr[len])))
{
bIsSupported = AL_TRUE;
break;
}
if((ptr=strchr(ptr, ' ')) != NULL)
{
do {
++ptr;
} while(isspace(*ptr));
}
}
}
ALCcontext_DecRef(Context);
return bIsSupported;
}
AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName)
{
if(!funcName)
return NULL;
return alcGetProcAddress(NULL, funcName);
}
AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName)
{
ALsizei i;
for(i = 0;EffectList[i].ename;i++)
{
if(DisabledEffects[EffectList[i].type] &&
strcmp(EffectList[i].ename, enumName) == 0)
return (ALenum)0;
}
i = 0;
while(enumeration[i].enumName &&
strcmp(enumeration[i].enumName, enumName) != 0)
i++;
return enumeration[i].value;
}
+486
View File
@@ -0,0 +1,486 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2007 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "config.h"
#include <stdlib.h>
#include "AL/al.h"
#include "AL/alc.h"
#include "alMain.h"
#include "alFilter.h"
#include "alThunk.h"
#include "alError.h"
static void InitFilterParams(ALfilter *filter, ALenum type);
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
ALCcontext *Context;
ALsizei i;
Context = GetContextRef();
if(!Context) return;
if(n < 0 || IsBadWritePtr((void*)filters, n * sizeof(ALuint)))
alSetError(Context, AL_INVALID_VALUE);
else
{
ALCdevice *device = Context->Device;
ALenum err;
for(i = 0;i < n;i++)
{
ALfilter *filter = calloc(1, sizeof(ALfilter));
if(!filter)
{
alSetError(Context, AL_OUT_OF_MEMORY);
alDeleteFilters(i, filters);
break;
}
InitFilterParams(filter, AL_FILTER_NULL);
err = NewThunkEntry(&filter->filter);
if(err == AL_NO_ERROR)
err = InsertUIntMapEntry(&device->FilterMap, filter->filter, filter);
if(err != AL_NO_ERROR)
{
FreeThunkEntry(filter->filter);
memset(filter, 0, sizeof(ALfilter));
free(filter);
alSetError(Context, err);
alDeleteFilters(i, filters);
break;
}
filters[i] = filter->filter;
}
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters)
{
ALCcontext *Context;
ALCdevice *device;
ALfilter *ALFilter;
ALsizei i;
Context = GetContextRef();
if(!Context) return;
device = Context->Device;
if(n < 0)
alSetError(Context, AL_INVALID_VALUE);
else
{
// Check that all filters are valid
for(i = 0;i < n;i++)
{
if(!filters[i])
continue;
if(LookupFilter(device, filters[i]) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
n = 0;
break;
}
}
for(i = 0;i < n;i++)
{
// Recheck that the filter is valid, because there could be duplicated names
if((ALFilter=RemoveFilter(device, filters[i])) == NULL)
continue;
FreeThunkEntry(ALFilter->filter);
memset(ALFilter, 0, sizeof(ALfilter));
free(ALFilter);
}
}
ALCcontext_DecRef(Context);
}
AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter)
{
ALCcontext *Context;
ALboolean result;
Context = GetContextRef();
if(!Context) return AL_FALSE;
result = ((!filter || LookupFilter(Context->Device, filter)) ?
AL_TRUE : AL_FALSE);
ALCcontext_DecRef(Context);
return result;
}
AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
switch(param)
{
case AL_FILTER_TYPE:
if(iValue == AL_FILTER_NULL || iValue == AL_FILTER_LOWPASS)
InitFilterParams(ALFilter, iValue);
else
alSetError(Context, AL_INVALID_VALUE);
break;
default:
/* Call the appropriate handler */
ALfilter_SetParami(ALFilter, Context, param, iValue);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
switch(param)
{
case AL_FILTER_TYPE:
alFilteri(filter, param, piValues[0]);
return;
}
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_SetParamiv(ALFilter, Context, param, piValues);
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_SetParamf(ALFilter, Context, param, flValue);
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_SetParamfv(ALFilter, Context, param, pflValues);
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
switch(param)
{
case AL_FILTER_TYPE:
*piValue = ALFilter->type;
break;
default:
/* Call the appropriate handler */
ALfilter_GetParami(ALFilter, Context, param, piValue);
break;
}
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
switch(param)
{
case AL_FILTER_TYPE:
alGetFilteri(filter, param, piValues);
return;
}
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_GetParamiv(ALFilter, Context, param, piValues);
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_GetParamf(ALFilter, Context, param, pflValue);
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
{
ALCcontext *Context;
ALCdevice *Device;
ALfilter *ALFilter;
Context = GetContextRef();
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_GetParamfv(ALFilter, Context, param, pflValues);
}
else
alSetError(Context, AL_INVALID_NAME);
ALCcontext_DecRef(Context);
}
ALfloat lpCoeffCalc(ALfloat g, ALfloat cw)
{
ALfloat a = 0.0f;
/* Be careful with gains < 0.001, as that causes the coefficient head
* towards 1, which will flatten the signal */
if(g < 0.9999f) /* 1-epsilon */
{
g = maxf(g, 0.001f);
a = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) /
(1 - g);
}
return a;
}
static void lp_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val)
{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
static void lp_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals)
{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
static void lp_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val)
{
switch(param)
{
case AL_LOWPASS_GAIN:
if(val >= AL_LOWPASS_MIN_GAIN && val <= AL_LOWPASS_MAX_GAIN)
filter->Gain = val;
else
alSetError(context, AL_INVALID_VALUE);
break;
case AL_LOWPASS_GAINHF:
if(val >= AL_LOWPASS_MIN_GAINHF && val <= AL_LOWPASS_MAX_GAINHF)
filter->GainHF = val;
else
alSetError(context, AL_INVALID_VALUE);
break;
default:
alSetError(context, AL_INVALID_ENUM);
break;
}
}
static void lp_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals)
{
lp_SetParamf(filter, context, param, vals[0]);
}
static void lp_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val)
{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
static void lp_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals)
{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
static void lp_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val)
{
switch(param)
{
case AL_LOWPASS_GAIN:
*val = filter->Gain;
break;
case AL_LOWPASS_GAINHF:
*val = filter->GainHF;
break;
default:
alSetError(context, AL_INVALID_ENUM);
break;
}
}
static void lp_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals)
{
lp_GetParamf(filter, context, param, vals);
}
static void null_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val)
{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
static void null_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals)
{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
static void null_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val)
{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
static void null_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals)
{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
static void null_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val)
{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
static void null_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals)
{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
static void null_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val)
{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
static void null_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals)
{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
ALvoid ReleaseALFilters(ALCdevice *device)
{
ALsizei i;
for(i = 0;i < device->FilterMap.size;i++)
{
ALfilter *temp = device->FilterMap.array[i].value;
device->FilterMap.array[i].value = NULL;
// Release filter structure
FreeThunkEntry(temp->filter);
memset(temp, 0, sizeof(ALfilter));
free(temp);
}
}
static void InitFilterParams(ALfilter *filter, ALenum type)
{
if(type == AL_FILTER_LOWPASS)
{
filter->Gain = AL_LOWPASS_DEFAULT_GAIN;
filter->GainHF = AL_LOWPASS_DEFAULT_GAINHF;
filter->SetParami = lp_SetParami;
filter->SetParamiv = lp_SetParamiv;
filter->SetParamf = lp_SetParamf;
filter->SetParamfv = lp_SetParamfv;
filter->GetParami = lp_GetParami;
filter->GetParamiv = lp_GetParamiv;
filter->GetParamf = lp_GetParamf;
filter->GetParamfv = lp_GetParamfv;
}
else
{
filter->SetParami = null_SetParami;
filter->SetParamiv = null_SetParamiv;
filter->SetParamf = null_SetParamf;
filter->SetParamfv = null_SetParamfv;
filter->GetParami = null_GetParami;
filter->GetParamiv = null_GetParamiv;
filter->GetParamf = null_GetParamf;
filter->GetParamfv = null_GetParamfv;
}
filter->type = type;
}
@@ -0,0 +1,483 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2000 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "config.h"
#include "alMain.h"
#include "AL/alc.h"
#include "alError.h"
#include "alListener.h"
#include "alSource.h"
AL_API ALvoid AL_APIENTRY alListenerf(ALenum eParam, ALfloat flValue)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
switch(eParam)
{
case AL_GAIN:
if(flValue >= 0.0f && isfinite(flValue))
{
Context->Listener.Gain = flValue;
Context->UpdateSources = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
break;
case AL_METERS_PER_UNIT:
if(flValue > 0.0f && isfinite(flValue))
{
Context->Listener.MetersPerUnit = flValue;
Context->UpdateSources = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
switch(eParam)
{
case AL_POSITION:
if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
{
LockContext(Context);
Context->Listener.Position[0] = flValue1;
Context->Listener.Position[1] = flValue2;
Context->Listener.Position[2] = flValue3;
Context->UpdateSources = AL_TRUE;
UnlockContext(Context);
}
else
alSetError(Context, AL_INVALID_VALUE);
break;
case AL_VELOCITY:
if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
{
LockContext(Context);
Context->Listener.Velocity[0] = flValue1;
Context->Listener.Velocity[1] = flValue2;
Context->Listener.Velocity[2] = flValue3;
Context->UpdateSources = AL_TRUE;
UnlockContext(Context);
}
else
alSetError(Context, AL_INVALID_VALUE);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
{
ALCcontext *Context;
if(pflValues)
{
switch(eParam)
{
case AL_GAIN:
case AL_METERS_PER_UNIT:
alListenerf(eParam, pflValues[0]);
return;
case AL_POSITION:
case AL_VELOCITY:
alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]);
return;
}
}
Context = GetContextRef();
if(!Context) return;
if(pflValues)
{
switch(eParam)
{
case AL_ORIENTATION:
if(isfinite(pflValues[0]) && isfinite(pflValues[1]) &&
isfinite(pflValues[2]) && isfinite(pflValues[3]) &&
isfinite(pflValues[4]) && isfinite(pflValues[5]))
{
LockContext(Context);
// AT then UP
Context->Listener.Forward[0] = pflValues[0];
Context->Listener.Forward[1] = pflValues[1];
Context->Listener.Forward[2] = pflValues[2];
Context->Listener.Up[0] = pflValues[3];
Context->Listener.Up[1] = pflValues[4];
Context->Listener.Up[2] = pflValues[5];
Context->UpdateSources = AL_TRUE;
UnlockContext(Context);
}
else
alSetError(Context, AL_INVALID_VALUE);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alListeneri(ALenum eParam, ALint lValue)
{
ALCcontext *Context;
(void)lValue;
Context = GetContextRef();
if(!Context) return;
switch(eParam)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
}
AL_API void AL_APIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3)
{
ALCcontext *Context;
switch(eParam)
{
case AL_POSITION:
case AL_VELOCITY:
alListener3f(eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3);
return;
}
Context = GetContextRef();
if(!Context) return;
switch(eParam)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
}
AL_API void AL_APIENTRY alListeneriv( ALenum eParam, const ALint* plValues )
{
ALCcontext *Context;
ALfloat flValues[6];
if(plValues)
{
switch(eParam)
{
case AL_POSITION:
case AL_VELOCITY:
alListener3f(eParam, (ALfloat)plValues[0], (ALfloat)plValues[1], (ALfloat)plValues[2]);
return;
case AL_ORIENTATION:
flValues[0] = (ALfloat)plValues[0];
flValues[1] = (ALfloat)plValues[1];
flValues[2] = (ALfloat)plValues[2];
flValues[3] = (ALfloat)plValues[3];
flValues[4] = (ALfloat)plValues[4];
flValues[5] = (ALfloat)plValues[5];
alListenerfv(eParam, flValues);
return;
}
}
Context = GetContextRef();
if(!Context) return;
if(plValues)
{
switch(eParam)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(pflValue)
{
switch(eParam)
{
case AL_GAIN:
*pflValue = Context->Listener.Gain;
break;
case AL_METERS_PER_UNIT:
*pflValue = Context->Listener.MetersPerUnit;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALfloat *pflValue2, ALfloat *pflValue3)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(pflValue1 && pflValue2 && pflValue3)
{
switch(eParam)
{
case AL_POSITION:
LockContext(Context);
*pflValue1 = Context->Listener.Position[0];
*pflValue2 = Context->Listener.Position[1];
*pflValue3 = Context->Listener.Position[2];
UnlockContext(Context);
break;
case AL_VELOCITY:
LockContext(Context);
*pflValue1 = Context->Listener.Velocity[0];
*pflValue2 = Context->Listener.Velocity[1];
*pflValue3 = Context->Listener.Velocity[2];
UnlockContext(Context);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues)
{
ALCcontext *Context;
switch(eParam)
{
case AL_GAIN:
case AL_METERS_PER_UNIT:
alGetListenerf(eParam, pflValues);
return;
case AL_POSITION:
case AL_VELOCITY:
alGetListener3f(eParam, pflValues+0, pflValues+1, pflValues+2);
return;
}
Context = GetContextRef();
if(!Context) return;
if(pflValues)
{
switch(eParam)
{
case AL_ORIENTATION:
LockContext(Context);
// AT then UP
pflValues[0] = Context->Listener.Forward[0];
pflValues[1] = Context->Listener.Forward[1];
pflValues[2] = Context->Listener.Forward[2];
pflValues[3] = Context->Listener.Up[0];
pflValues[4] = Context->Listener.Up[1];
pflValues[5] = Context->Listener.Up[2];
UnlockContext(Context);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum eParam, ALint *plValue)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(plValue)
{
switch(eParam)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API void AL_APIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plValue2, ALint *plValue3)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(plValue1 && plValue2 && plValue3)
{
switch (eParam)
{
case AL_POSITION:
LockContext(Context);
*plValue1 = (ALint)Context->Listener.Position[0];
*plValue2 = (ALint)Context->Listener.Position[1];
*plValue3 = (ALint)Context->Listener.Position[2];
UnlockContext(Context);
break;
case AL_VELOCITY:
LockContext(Context);
*plValue1 = (ALint)Context->Listener.Velocity[0];
*plValue2 = (ALint)Context->Listener.Velocity[1];
*plValue3 = (ALint)Context->Listener.Velocity[2];
UnlockContext(Context);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API void AL_APIENTRY alGetListeneriv(ALenum eParam, ALint* plValues)
{
ALCcontext *Context;
switch(eParam)
{
case AL_POSITION:
case AL_VELOCITY:
alGetListener3i(eParam, plValues+0, plValues+1, plValues+2);
return;
}
Context = GetContextRef();
if(!Context) return;
if(plValues)
{
switch(eParam)
{
case AL_ORIENTATION:
LockContext(Context);
// AT then UP
plValues[0] = (ALint)Context->Listener.Forward[0];
plValues[1] = (ALint)Context->Listener.Forward[1];
plValues[2] = (ALint)Context->Listener.Forward[2];
plValues[3] = (ALint)Context->Listener.Up[0];
plValues[4] = (ALint)Context->Listener.Up[1];
plValues[5] = (ALint)Context->Listener.Up[2];
UnlockContext(Context);
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
File diff suppressed because it is too large Load Diff
+662
View File
@@ -0,0 +1,662 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2000 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "config.h"
#include <stdlib.h>
#include "alMain.h"
#include "AL/alc.h"
#include "AL/alext.h"
#include "alError.h"
#include "alSource.h"
#include "alAuxEffectSlot.h"
#include "alState.h"
static const ALchar alVendor[] = "OpenAL Community";
static const ALchar alVersion[] = "1.1 ALSOFT "ALSOFT_VERSION;
static const ALchar alRenderer[] = "OpenAL Soft";
// Error Messages
static const ALchar alNoError[] = "No Error";
static const ALchar alErrInvalidName[] = "Invalid Name";
static const ALchar alErrInvalidEnum[] = "Invalid Enum";
static const ALchar alErrInvalidValue[] = "Invalid Value";
static const ALchar alErrInvalidOp[] = "Invalid Operation";
static const ALchar alErrOutOfMemory[] = "Out of Memory";
AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
Context->SourceDistanceModel = AL_TRUE;
Context->UpdateSources = AL_TRUE;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
Context->SourceDistanceModel = AL_FALSE;
Context->UpdateSources = AL_TRUE;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
}
AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
{
ALCcontext *Context;
ALboolean value=AL_FALSE;
Context = GetContextRef();
if(!Context) return AL_FALSE;
switch(capability)
{
case AL_SOURCE_DISTANCE_MODEL:
value = Context->SourceDistanceModel;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
return value;
}
AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
{
ALCcontext *Context;
ALboolean value=AL_FALSE;
Context = GetContextRef();
if(!Context) return AL_FALSE;
switch(pname)
{
case AL_DOPPLER_FACTOR:
if(Context->DopplerFactor != 0.0f)
value = AL_TRUE;
break;
case AL_DOPPLER_VELOCITY:
if(Context->DopplerVelocity != 0.0f)
value = AL_TRUE;
break;
case AL_DISTANCE_MODEL:
if(Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED)
value = AL_TRUE;
break;
case AL_SPEED_OF_SOUND:
if(Context->flSpeedOfSound != 0.0f)
value = AL_TRUE;
break;
case AL_DEFERRED_UPDATES_SOFT:
value = Context->DeferUpdates;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
return value;
}
AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
{
ALCcontext *Context;
ALdouble value = 0.0;
Context = GetContextRef();
if(!Context) return 0.0;
switch(pname)
{
case AL_DOPPLER_FACTOR:
value = (double)Context->DopplerFactor;
break;
case AL_DOPPLER_VELOCITY:
value = (double)Context->DopplerVelocity;
break;
case AL_DISTANCE_MODEL:
value = (double)Context->DistanceModel;
break;
case AL_SPEED_OF_SOUND:
value = (double)Context->flSpeedOfSound;
break;
case AL_DEFERRED_UPDATES_SOFT:
value = (ALdouble)Context->DeferUpdates;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
return value;
}
AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
{
ALCcontext *Context;
ALfloat value = 0.0f;
Context = GetContextRef();
if(!Context) return 0.0f;
switch(pname)
{
case AL_DOPPLER_FACTOR:
value = Context->DopplerFactor;
break;
case AL_DOPPLER_VELOCITY:
value = Context->DopplerVelocity;
break;
case AL_DISTANCE_MODEL:
value = (float)Context->DistanceModel;
break;
case AL_SPEED_OF_SOUND:
value = Context->flSpeedOfSound;
break;
case AL_DEFERRED_UPDATES_SOFT:
value = (ALfloat)Context->DeferUpdates;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
return value;
}
AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
{
ALCcontext *Context;
ALint value = 0;
Context = GetContextRef();
if(!Context) return 0;
switch(pname)
{
case AL_DOPPLER_FACTOR:
value = (ALint)Context->DopplerFactor;
break;
case AL_DOPPLER_VELOCITY:
value = (ALint)Context->DopplerVelocity;
break;
case AL_DISTANCE_MODEL:
value = (ALint)Context->DistanceModel;
break;
case AL_SPEED_OF_SOUND:
value = (ALint)Context->flSpeedOfSound;
break;
case AL_DEFERRED_UPDATES_SOFT:
value = (ALint)Context->DeferUpdates;
break;
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
return value;
}
AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname,ALboolean *data)
{
ALCcontext *Context;
if(data)
{
switch(pname)
{
case AL_DOPPLER_FACTOR:
case AL_DOPPLER_VELOCITY:
case AL_DISTANCE_MODEL:
case AL_SPEED_OF_SOUND:
case AL_DEFERRED_UPDATES_SOFT:
*data = alGetBoolean(pname);
return;
}
}
Context = GetContextRef();
if(!Context) return;
if(data)
{
switch(pname)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
{
// data is a NULL pointer
alSetError(Context, AL_INVALID_VALUE);
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname,ALdouble *data)
{
ALCcontext *Context;
if(data)
{
switch(pname)
{
case AL_DOPPLER_FACTOR:
case AL_DOPPLER_VELOCITY:
case AL_DISTANCE_MODEL:
case AL_SPEED_OF_SOUND:
case AL_DEFERRED_UPDATES_SOFT:
*data = alGetDouble(pname);
return;
}
}
Context = GetContextRef();
if(!Context) return;
if(data)
{
switch(pname)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
{
// data is a NULL pointer
alSetError(Context, AL_INVALID_VALUE);
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname,ALfloat *data)
{
ALCcontext *Context;
if(data)
{
switch(pname)
{
case AL_DOPPLER_FACTOR:
case AL_DOPPLER_VELOCITY:
case AL_DISTANCE_MODEL:
case AL_SPEED_OF_SOUND:
case AL_DEFERRED_UPDATES_SOFT:
*data = alGetFloat(pname);
return;
}
}
Context = GetContextRef();
if(!Context) return;
if(data)
{
switch(pname)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
{
// data is a NULL pointer
alSetError(Context, AL_INVALID_VALUE);
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname,ALint *data)
{
ALCcontext *Context;
if(data)
{
switch(pname)
{
case AL_DOPPLER_FACTOR:
case AL_DOPPLER_VELOCITY:
case AL_DISTANCE_MODEL:
case AL_SPEED_OF_SOUND:
case AL_DEFERRED_UPDATES_SOFT:
*data = alGetInteger(pname);
return;
}
}
Context = GetContextRef();
if(!Context) return;
if(data)
{
switch(pname)
{
default:
alSetError(Context, AL_INVALID_ENUM);
break;
}
}
else
{
// data is a NULL pointer
alSetError(Context, AL_INVALID_VALUE);
}
ALCcontext_DecRef(Context);
}
AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname)
{
const ALchar *value;
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return NULL;
switch(pname)
{
case AL_VENDOR:
value=alVendor;
break;
case AL_VERSION:
value=alVersion;
break;
case AL_RENDERER:
value=alRenderer;
break;
case AL_EXTENSIONS:
value=Context->ExtensionList;
break;
case AL_NO_ERROR:
value=alNoError;
break;
case AL_INVALID_NAME:
value=alErrInvalidName;
break;
case AL_INVALID_ENUM:
value=alErrInvalidEnum;
break;
case AL_INVALID_VALUE:
value=alErrInvalidValue;
break;
case AL_INVALID_OPERATION:
value=alErrInvalidOp;
break;
case AL_OUT_OF_MEMORY:
value=alErrOutOfMemory;
break;
default:
value=NULL;
alSetError(Context, AL_INVALID_ENUM);
break;
}
ALCcontext_DecRef(Context);
return value;
}
AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(value >= 0.0f && isfinite(value))
{
Context->DopplerFactor = value;
Context->UpdateSources = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(value > 0.0f && isfinite(value))
{
Context->DopplerVelocity=value;
Context->UpdateSources = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat flSpeedOfSound)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(flSpeedOfSound > 0.0f && isfinite(flSpeedOfSound))
{
Context->flSpeedOfSound = flSpeedOfSound;
Context->UpdateSources = AL_TRUE;
}
else
alSetError(Context, AL_INVALID_VALUE);
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
switch(value)
{
case AL_NONE:
case AL_INVERSE_DISTANCE:
case AL_INVERSE_DISTANCE_CLAMPED:
case AL_LINEAR_DISTANCE:
case AL_LINEAR_DISTANCE_CLAMPED:
case AL_EXPONENT_DISTANCE:
case AL_EXPONENT_DISTANCE_CLAMPED:
Context->DistanceModel = value;
Context->UpdateSources = AL_TRUE;
break;
default:
alSetError(Context, AL_INVALID_VALUE);
break;
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(!Context->DeferUpdates)
{
ALboolean UpdateSources;
ALsource **src, **src_end;
ALeffectslot **slot, **slot_end;
int fpuState;
fpuState = SetMixerFPUMode();
LockContext(Context);
Context->DeferUpdates = AL_TRUE;
/* Make sure all pending updates are performed */
UpdateSources = ExchangeInt(&Context->UpdateSources, AL_FALSE);
src = Context->ActiveSources;
src_end = src + Context->ActiveSourceCount;
while(src != src_end)
{
if((*src)->state != AL_PLAYING)
{
Context->ActiveSourceCount--;
*src = *(--src_end);
continue;
}
if(ExchangeInt(&(*src)->NeedsUpdate, AL_FALSE) || UpdateSources)
ALsource_Update(*src, Context);
src++;
}
slot = Context->ActiveEffectSlots;
slot_end = slot + Context->ActiveEffectSlotCount;
while(slot != slot_end)
{
if(ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE))
ALeffectState_Update((*slot)->EffectState, Context, *slot);
slot++;
}
UnlockContext(Context);
RestoreFPUMode(fpuState);
}
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
{
ALCcontext *Context;
Context = GetContextRef();
if(!Context) return;
if(ExchangeInt(&Context->DeferUpdates, AL_FALSE))
{
ALsizei pos;
LockContext(Context);
LockUIntMapRead(&Context->SourceMap);
for(pos = 0;pos < Context->SourceMap.size;pos++)
{
ALsource *Source = Context->SourceMap.array[pos].value;
ALenum new_state;
if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) &&
Source->lOffset != -1)
ApplyOffset(Source);
new_state = ExchangeInt(&Source->new_state, AL_NONE);
if(new_state)
SetSourceState(Source, Context, new_state);
}
UnlockUIntMapRead(&Context->SourceMap);
UnlockContext(Context);
}
ALCcontext_DecRef(Context);
}
@@ -0,0 +1,89 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2007 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "config.h"
#include <stdlib.h>
#include "alMain.h"
#include "alThunk.h"
static ALenum *ThunkArray;
static ALuint ThunkArraySize;
static RWLock ThunkLock;
void ThunkInit(void)
{
RWLockInit(&ThunkLock);
ThunkArraySize = 1;
ThunkArray = calloc(1, ThunkArraySize * sizeof(*ThunkArray));
}
void ThunkExit(void)
{
free(ThunkArray);
ThunkArray = NULL;
ThunkArraySize = 0;
}
ALenum NewThunkEntry(ALuint *index)
{
ALenum *NewList;
ALuint i;
ReadLock(&ThunkLock);
for(i = 0;i < ThunkArraySize;i++)
{
if(ExchangeInt(&ThunkArray[i], AL_TRUE) == AL_FALSE)
{
ReadUnlock(&ThunkLock);
*index = i+1;
return AL_NO_ERROR;
}
}
ReadUnlock(&ThunkLock);
WriteLock(&ThunkLock);
NewList = realloc(ThunkArray, ThunkArraySize*2 * sizeof(*ThunkArray));
if(!NewList)
{
WriteUnlock(&ThunkLock);
ERR("Realloc failed to increase to %u enties!\n", ThunkArraySize*2);
return AL_OUT_OF_MEMORY;
}
memset(&NewList[ThunkArraySize], 0, ThunkArraySize*sizeof(*ThunkArray));
ThunkArraySize *= 2;
ThunkArray = NewList;
ThunkArray[i] = AL_TRUE;
WriteUnlock(&ThunkLock);
*index = i+1;
return AL_NO_ERROR;
}
void FreeThunkEntry(ALuint index)
{
ReadLock(&ThunkLock);
if(index > 0 && index <= ThunkArraySize)
ExchangeInt(&ThunkArray[index-1], AL_FALSE);
ReadUnlock(&ThunkLock);
}
+150
View File
@@ -0,0 +1,150 @@
/* API declaration export attribute */
#define AL_API __attribute__((visibility("protected")))
#define ALC_API __attribute__((visibility("protected")))
/* Define to the library version */
#define ALSOFT_VERSION "1.13"
/* Define if we have the ALSA backend */
/* #undef HAVE_ALSA */
/* Define if we have the OSS backend */
/* #undef HAVE_OSS */
/* Define if we have the Solaris backend */
/* #undef HAVE_SOLARIS */
/* Define if we have the SndIO backend */
/* #undef HAVE_SNDIO */
/* Define if we have the MMDevApi backend */
/* #undef HAVE_MMDEVAPI */
/* Define if we have the DSound backend */
/* #undef HAVE_DSOUND */
/* Define if we have the Windows Multimedia backend */
/* #undef HAVE_WINMM */
/* Define if we have the PortAudio backend */
/* #undef HAVE_PORTAUDIO */
/* Define if we have the PulseAudio backend */
/* #undef HAVE_PULSEAUDIO */
/* Define if we have the CoreAudio backend */
/* #undef HAVE_COREAUDIO */
/* Define if we have the OpenSL backend */
/* #undef HAVE_OPENSL */
/* Define if we have the OpenSL 1.1 backend */
/* #undef HAVE_OPENSL_1_1 */
/* Define if we have the Android backend */
#define HAVE_ANDROID
/* Define if we want to use the low latency Android backend */
/* #undef HAVE_ANDROID_LOW_LATENCY */
/* Define if we have the Wave Writer backend */
#define HAVE_WAVE
/* Define if we have dlfcn.h */
#define HAVE_DLFCN_H
/* Define if we have the stat function */
#define HAVE_STAT
/* Define if we have the powf function */
#define HAVE_POWF
/* Define if we have the sqrtf function */
#define HAVE_SQRTF
/* Define if we have the cosf function */
#define HAVE_COSF
/* Define if we have the sinf function */
#define HAVE_SINF
/* Define if we have the acosf function */
#define HAVE_ACOSF
/* Define if we have the asinf function */
#define HAVE_ASINF
/* Define if we have the atanf function */
#define HAVE_ATANF
/* Define if we have the atan2f function */
#define HAVE_ATAN2F
/* Define if we have the fabsf function */
#define HAVE_FABSF
/* Define if we have the log10f function */
#define HAVE_LOG10F
/* Define if we have the floorf function */
#define HAVE_FLOORF
/* Define if we have the strtof function */
/* #undef HAVE_STRTOF */
/* Define if we have stdint.h */
#define HAVE_STDINT_H
/* Define if we have the __int64 type */
/* #undef HAVE___INT64 */
/* Define to the size of a long int type */
#define SIZEOF_LONG 4
/* Define to the size of a long long int type */
#define SIZEOF_LONG_LONG 8
/* Define if we have GCC's destructor attribute */
#define HAVE_GCC_DESTRUCTOR
/* Define if we have GCC's format attribute */
#define HAVE_GCC_FORMAT
/* Define if we have pthread_np.h */
/* #undef HAVE_PTHREAD_NP_H */
/* Define if we have arm_neon.h */
/* #undef HAVE_ARM_NEON_H */
/* Define if we have guiddef.h */
/* #undef HAVE_GUIDDEF_H */
/* Define if we have guiddef.h */
/* #undef HAVE_INITGUID_H */
/* Define if we have ieeefp.h */
/* #undef HAVE_IEEEFP_H */
/* Define if we have float.h */
#define HAVE_FLOAT_H
/* Define if we have fpu_control.h */
/* #undef HAVE_FPU_CONTROL_H */
/* Define if we have fenv.h */
/* #undef HAVE_FENV_H */
/* Define if we have fesetround() */
/* #undef HAVE_FESETROUND */
/* Define if we have _controlfp() */
/* #undef HAVE__CONTROLFP */
/* Define if we have pthread_setschedparam() */
/* #undef HAVE_PTHREAD_SETSCHEDPARAM */
/* Define if we have the restrict keyword */
/* #undef HAVE_RESTRICT */
/* Define if we have the __restrict keyword */
#define HAVE___RESTRICT