mirror of
https://github.com/love2d/megasource.git
synced 2026-08-24 06:27:04 +02:00
Add OpenAL-Soft 1.15.1.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#ifndef _AL_AUXEFFECTSLOT_H_
|
||||
#define _AL_AUXEFFECTSLOT_H_
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alEffect.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ALeffectState {
|
||||
ALvoid (*Destroy)(struct ALeffectState *State);
|
||||
ALboolean (*DeviceUpdate)(struct ALeffectState *State, ALCdevice *Device);
|
||||
ALvoid (*Update)(struct ALeffectState *State, ALCdevice *Device, const struct ALeffectslot *Slot);
|
||||
ALvoid (*Process)(struct ALeffectState *State, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE]);
|
||||
} ALeffectState;
|
||||
|
||||
|
||||
typedef struct ALeffectslot
|
||||
{
|
||||
ALeffect effect;
|
||||
|
||||
volatile ALfloat Gain;
|
||||
volatile ALboolean AuxSendAuto;
|
||||
|
||||
volatile ALenum NeedsUpdate;
|
||||
ALeffectState *EffectState;
|
||||
|
||||
ALIGN(16) ALfloat WetBuffer[1][BUFFERSIZE];
|
||||
|
||||
ALfloat ClickRemoval[1];
|
||||
ALfloat PendingClicks[1];
|
||||
|
||||
RefCount ref;
|
||||
|
||||
/* Self ID */
|
||||
ALuint id;
|
||||
} ALeffectslot;
|
||||
|
||||
|
||||
ALenum InitEffectSlot(ALeffectslot *slot);
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
|
||||
|
||||
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)))
|
||||
|
||||
ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
#ifndef _AL_BUFFER_H_
|
||||
#define _AL_BUFFER_H_
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* User formats */
|
||||
enum UserFmtType {
|
||||
UserFmtByte = AL_BYTE_SOFT,
|
||||
UserFmtUByte = AL_UNSIGNED_BYTE_SOFT,
|
||||
UserFmtShort = AL_SHORT_SOFT,
|
||||
UserFmtUShort = AL_UNSIGNED_SHORT_SOFT,
|
||||
UserFmtInt = AL_INT_SOFT,
|
||||
UserFmtUInt = AL_UNSIGNED_INT_SOFT,
|
||||
UserFmtFloat = AL_FLOAT_SOFT,
|
||||
UserFmtDouble = AL_DOUBLE_SOFT,
|
||||
UserFmtByte3 = AL_BYTE3_SOFT,
|
||||
UserFmtUByte3 = AL_UNSIGNED_BYTE3_SOFT,
|
||||
UserFmtMulaw,
|
||||
UserFmtAlaw,
|
||||
UserFmtIMA4,
|
||||
};
|
||||
enum UserFmtChannels {
|
||||
UserFmtMono = AL_MONO_SOFT,
|
||||
UserFmtStereo = AL_STEREO_SOFT,
|
||||
UserFmtRear = AL_REAR_SOFT,
|
||||
UserFmtQuad = AL_QUAD_SOFT,
|
||||
UserFmtX51 = AL_5POINT1_SOFT, /* (WFX order) */
|
||||
UserFmtX61 = AL_6POINT1_SOFT, /* (WFX order) */
|
||||
UserFmtX71 = AL_7POINT1_SOFT, /* (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;
|
||||
|
||||
/* Number of times buffer was attached to a source (deletion can only occur when 0) */
|
||||
RefCount ref;
|
||||
|
||||
RWLock lock;
|
||||
|
||||
/* Self ID */
|
||||
ALuint id;
|
||||
} ALbuffer;
|
||||
|
||||
ALvoid ReleaseALBuffers(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,114 @@
|
||||
#ifndef _AL_EFFECT_H_
|
||||
#define _AL_EFFECT_H_
|
||||
|
||||
#include "alMain.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);
|
||||
|
||||
/* Self ID */
|
||||
ALuint id;
|
||||
} 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; }
|
||||
|
||||
ALenum InitEffect(ALeffect *effect);
|
||||
ALvoid ReleaseALEffects(ALCdevice *device);
|
||||
|
||||
ALvoid LoadReverbPreset(const char *name, ALeffect *effect);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef _AL_ERROR_H_
|
||||
#define _AL_ERROR_H_
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ALboolean TrapALError;
|
||||
|
||||
ALvoid alSetError(ALCcontext *Context, ALenum errorCode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef _AL_FILTER_H_
|
||||
#define _AL_FILTER_H_
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOWPASSFREQREF (5000)
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Self ID */
|
||||
ALuint id;
|
||||
} 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,28 @@
|
||||
#ifndef _AL_LISTENER_H_
|
||||
#define _AL_LISTENER_H_
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ALlistener {
|
||||
volatile ALfloat Position[3];
|
||||
volatile ALfloat Velocity[3];
|
||||
volatile ALfloat Forward[3];
|
||||
volatile ALfloat Up[3];
|
||||
volatile ALfloat Gain;
|
||||
volatile ALfloat MetersPerUnit;
|
||||
|
||||
struct {
|
||||
ALfloat Matrix[4][4];
|
||||
ALfloat Velocity[3];
|
||||
} Params;
|
||||
} ALlistener;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,884 @@
|
||||
#ifndef AL_MAIN_H
|
||||
#define AL_MAIN_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_FENV_H
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
|
||||
#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;
|
||||
|
||||
#define MAKEU64(x,y) (((ALuint64)(x)<<32)|(ALuint64)(y))
|
||||
|
||||
#ifdef HAVE_GCC_FORMAT
|
||||
#define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
|
||||
#else
|
||||
#define PRINTF_STYLE(x, y)
|
||||
#endif
|
||||
|
||||
|
||||
static const union {
|
||||
ALuint u;
|
||||
ALubyte b[sizeof(ALuint)];
|
||||
} EndianTest = { 1 };
|
||||
#define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
|
||||
|
||||
#define COUNTOF(x) (sizeof((x))/sizeof((x)[0]))
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#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);
|
||||
|
||||
WCHAR *strdupW(const WCHAR *str);
|
||||
|
||||
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>
|
||||
#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
|
||||
|
||||
typedef void *volatile XchgPtr;
|
||||
|
||||
#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(XchgPtr *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(XchgPtr *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(XchgPtr *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(XchgPtr *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(XchgPtr *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(XchgPtr *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(XchgPtr *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(XchgPtr *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); }
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Hrtf;
|
||||
|
||||
|
||||
#define DEFAULT_OUTPUT_RATE (44100)
|
||||
#define MIN_OUTPUT_RATE (8000)
|
||||
|
||||
|
||||
// Find the next power-of-2 for non-power-of-2 numbers.
|
||||
static __inline ALuint NextPowerOf2(ALuint value)
|
||||
{
|
||||
if(value > 0)
|
||||
{
|
||||
value--;
|
||||
value |= value>>1;
|
||||
value |= value>>2;
|
||||
value |= value>>4;
|
||||
value |= value>>8;
|
||||
value |= value>>16;
|
||||
}
|
||||
return value+1;
|
||||
}
|
||||
|
||||
/* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
|
||||
* mode. */
|
||||
static __inline ALint fastf2i(ALfloat f)
|
||||
{
|
||||
#ifdef HAVE_LRINTF
|
||||
return lrintf(f);
|
||||
#elif defined(_MSC_VER) && defined(_M_IX86)
|
||||
ALint i;
|
||||
__asm fld f
|
||||
__asm fistp i
|
||||
return i;
|
||||
#else
|
||||
return (ALint)f;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 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 {
|
||||
ALL_DEVICE_PROBE,
|
||||
CAPTURE_DEVICE_PROBE
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
ALCenum (*OpenPlayback)(ALCdevice*, const ALCchar*);
|
||||
void (*ClosePlayback)(ALCdevice*);
|
||||
ALCboolean (*ResetPlayback)(ALCdevice*);
|
||||
ALCboolean (*StartPlayback)(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*);
|
||||
|
||||
void (*Lock)(ALCdevice*);
|
||||
void (*Unlock)(ALCdevice*);
|
||||
|
||||
ALint64 (*GetLatency)(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_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);
|
||||
|
||||
|
||||
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,
|
||||
|
||||
DefaultDistanceModel = InverseDistanceClamped
|
||||
};
|
||||
|
||||
enum Resampler {
|
||||
PointResampler,
|
||||
LinearResampler,
|
||||
CubicResampler,
|
||||
|
||||
ResamplerMax,
|
||||
};
|
||||
|
||||
enum Channel {
|
||||
FrontLeft = 0,
|
||||
FrontRight,
|
||||
FrontCenter,
|
||||
LFE,
|
||||
BackLeft,
|
||||
BackRight,
|
||||
BackCenter,
|
||||
SideLeft,
|
||||
SideRight,
|
||||
|
||||
MaxChannels,
|
||||
};
|
||||
|
||||
|
||||
/* Device formats */
|
||||
enum DevFmtType {
|
||||
DevFmtByte = ALC_BYTE_SOFT,
|
||||
DevFmtUByte = ALC_UNSIGNED_BYTE_SOFT,
|
||||
DevFmtShort = ALC_SHORT_SOFT,
|
||||
DevFmtUShort = ALC_UNSIGNED_SHORT_SOFT,
|
||||
DevFmtInt = ALC_INT_SOFT,
|
||||
DevFmtUInt = ALC_UNSIGNED_INT_SOFT,
|
||||
DevFmtFloat = ALC_FLOAT_SOFT,
|
||||
|
||||
DevFmtTypeDefault = DevFmtFloat
|
||||
};
|
||||
enum DevFmtChannels {
|
||||
DevFmtMono = ALC_MONO_SOFT,
|
||||
DevFmtStereo = ALC_STEREO_SOFT,
|
||||
DevFmtQuad = ALC_QUAD_SOFT,
|
||||
DevFmtX51 = ALC_5POINT1_SOFT,
|
||||
DevFmtX61 = ALC_6POINT1_SOFT,
|
||||
DevFmtX71 = ALC_7POINT1_SOFT,
|
||||
|
||||
/* Similar to 5.1, except using the side channels instead of back */
|
||||
DevFmtX51Side = 0x80000000,
|
||||
|
||||
DevFmtChannelsDefault = DevFmtStereo
|
||||
};
|
||||
|
||||
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[];
|
||||
|
||||
|
||||
enum DeviceType {
|
||||
Playback,
|
||||
Capture,
|
||||
Loopback
|
||||
};
|
||||
|
||||
|
||||
/* Size for temporary storage of buffer data, in ALfloats. Larger values need
|
||||
* more memory, 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, as well as the maximum number of samples per mixing iteration.
|
||||
*
|
||||
* The mixer requires being able to do two samplings per mixing loop. With the
|
||||
* cubic resampler (which requires 3 padding samples), this limits a 2048
|
||||
* buffer size to about 2044. This means that buffer_freq*source_pitch cannot
|
||||
* exceed device_freq*2044 for a 32-bit buffer.
|
||||
*/
|
||||
#ifndef BUFFERSIZE
|
||||
#define BUFFERSIZE 2048
|
||||
#endif
|
||||
|
||||
|
||||
struct ALCdevice_struct
|
||||
{
|
||||
volatile RefCount ref;
|
||||
|
||||
ALCboolean Connected;
|
||||
enum DeviceType Type;
|
||||
|
||||
CRITICAL_SECTION Mutex;
|
||||
|
||||
ALuint Frequency;
|
||||
ALuint UpdateSize;
|
||||
ALuint NumUpdates;
|
||||
enum DevFmtChannels FmtChans;
|
||||
enum DevFmtType FmtType;
|
||||
|
||||
ALCchar *DeviceName;
|
||||
|
||||
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;
|
||||
|
||||
ALuint ChannelOffsets[MaxChannels];
|
||||
|
||||
enum Channel Speaker2Chan[MaxChannels];
|
||||
ALfloat SpeakerAngle[MaxChannels];
|
||||
ALuint NumChan;
|
||||
|
||||
/* Temp storage used for mixing. +1 for the predictive sample. */
|
||||
ALIGN(16) ALfloat SampleData1[BUFFERSIZE+1];
|
||||
ALIGN(16) ALfloat SampleData2[BUFFERSIZE+1];
|
||||
|
||||
// Dry path buffer mix
|
||||
ALIGN(16) ALfloat DryBuffer[MaxChannels][BUFFERSIZE];
|
||||
|
||||
ALIGN(16) ALfloat ClickRemoval[MaxChannels];
|
||||
ALIGN(16) ALfloat PendingClicks[MaxChannels];
|
||||
|
||||
/* Default effect slot */
|
||||
struct ALeffectslot *DefaultSlot;
|
||||
|
||||
// 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_StartPlayback(a) ((a)->Funcs->StartPlayback((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)))
|
||||
#define ALCdevice_Lock(a) ((a)->Funcs->Lock((a)))
|
||||
#define ALCdevice_Unlock(a) ((a)->Funcs->Unlock((a)))
|
||||
#define ALCdevice_GetLatency(a) ((a)->Funcs->GetLatency((a)))
|
||||
|
||||
// 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)
|
||||
// Sample type was requested by the config file
|
||||
#define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
|
||||
|
||||
// Stereo sources cover 120-degree angles around +/-90
|
||||
#define DEVICE_WIDE_STEREO (1<<16)
|
||||
|
||||
// Specifies if the device is currently running
|
||||
#define DEVICE_RUNNING (1<<31)
|
||||
|
||||
/* Invalid channel offset */
|
||||
#define INVALID_OFFSET (~0u)
|
||||
|
||||
|
||||
#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;
|
||||
|
||||
struct 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 SpeedOfSound;
|
||||
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 AppendAllDevicesList(const ALCchar *name);
|
||||
void AppendCaptureDeviceList(const ALCchar *name);
|
||||
|
||||
void ALCdevice_LockDefault(ALCdevice *device);
|
||||
void ALCdevice_UnlockDefault(ALCdevice *device);
|
||||
ALint64 ALCdevice_GetLatencyDefault(ALCdevice *device);
|
||||
|
||||
static __inline void LockContext(ALCcontext *context)
|
||||
{ ALCdevice_Lock(context->Device); }
|
||||
static __inline void UnlockContext(ALCcontext *context)
|
||||
{ ALCdevice_Unlock(context->Device); }
|
||||
|
||||
|
||||
void *al_malloc(size_t alignment, size_t size);
|
||||
void *al_calloc(size_t alignment, size_t size);
|
||||
void al_free(void *ptr);
|
||||
|
||||
typedef struct {
|
||||
int state;
|
||||
#ifdef HAVE_SSE
|
||||
int sse_state;
|
||||
#endif
|
||||
} FPUCtl;
|
||||
void SetMixerFPUMode(FPUCtl *ctl);
|
||||
void RestoreFPUMode(const FPUCtl *ctl);
|
||||
|
||||
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 (7)
|
||||
#define HRIR_LENGTH (1<<HRIR_BITS)
|
||||
#define HRIR_MASK (HRIR_LENGTH-1)
|
||||
#define HRTFDELAY_BITS (20)
|
||||
#define HRTFDELAY_FRACONE (1<<HRTFDELAY_BITS)
|
||||
#define HRTFDELAY_MASK (HRTFDELAY_FRACONE-1)
|
||||
const struct Hrtf *GetHrtf(ALCdevice *device);
|
||||
void FreeHrtfs(void);
|
||||
ALuint GetHrtfIrSize (const struct Hrtf *Hrtf);
|
||||
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 *type, const char *func, const char *fmt, ...) PRINTF_STYLE(3,4);
|
||||
#define AL_PRINT(T, ...) al_print((T), __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("(II)", __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define WARN(...) do { \
|
||||
if(LogLevel >= LogWarning) \
|
||||
AL_PRINT("(WW)", __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define ERR(...) do { \
|
||||
if(LogLevel >= LogError) \
|
||||
AL_PRINT("(EE)", __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
|
||||
extern ALint RTPrioLevel;
|
||||
|
||||
|
||||
extern ALuint CPUCapFlags;
|
||||
enum {
|
||||
CPU_CAP_SSE = 1<<0,
|
||||
CPU_CAP_NEON = 1<<1,
|
||||
};
|
||||
|
||||
void FillCPUCaps(ALuint capfilter);
|
||||
|
||||
|
||||
/**
|
||||
* Starts a try block. Must not be nested within another try block within the
|
||||
* same function.
|
||||
*/
|
||||
#define al_try do { \
|
||||
int _al_err=0; \
|
||||
_al_try_label: \
|
||||
if(_al_err == 0)
|
||||
/**
|
||||
* After a try or another catch block, runs the next block if the given value
|
||||
* was thrown.
|
||||
*/
|
||||
#define al_catch(val) else if(_al_err == (val))
|
||||
/**
|
||||
* After a try or catch block, runs the next block for any value thrown and not
|
||||
* caught.
|
||||
*/
|
||||
#define al_catchany() else
|
||||
/** Marks the end of the final catch (or the try) block. */
|
||||
#define al_endtry } while(0)
|
||||
|
||||
/**
|
||||
* The given integer value is "thrown" so as to be caught by a catch block.
|
||||
* Must be called in a try block within the same function. The value must not
|
||||
* be 0.
|
||||
*/
|
||||
#define al_throw(e) do { \
|
||||
_al_err = (e); \
|
||||
assert(_al_err != 0); \
|
||||
goto _al_try_label; \
|
||||
} while(0)
|
||||
/** Sets an AL error on the given context, before throwing the error code. */
|
||||
#define al_throwerr(ctx, err) do { \
|
||||
alSetError((ctx), (err)); \
|
||||
al_throw((err)); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Throws an AL_INVALID_VALUE error with the given ctx if the given condition
|
||||
* is false.
|
||||
*/
|
||||
#define CHECK_VALUE(ctx, cond) do { \
|
||||
if(!(cond)) \
|
||||
al_throwerr((ctx), AL_INVALID_VALUE); \
|
||||
} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,190 @@
|
||||
#ifndef _AL_SOURCE_H_
|
||||
#define _AL_SOURCE_H_
|
||||
|
||||
#define MAX_SENDS 4
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alu.h"
|
||||
#include "alFilter.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[ResamplerMax];
|
||||
extern const ALsizei ResamplerPrePadding[ResamplerMax];
|
||||
|
||||
|
||||
typedef struct ALbufferlistitem
|
||||
{
|
||||
struct ALbuffer *buffer;
|
||||
struct ALbufferlistitem *next;
|
||||
struct ALbufferlistitem *prev;
|
||||
} ALbufferlistitem;
|
||||
|
||||
typedef struct HrtfState {
|
||||
ALboolean Moving;
|
||||
ALuint Counter;
|
||||
ALIGN(16) ALfloat History[MaxChannels][SRC_HISTORY_LENGTH];
|
||||
ALIGN(16) ALfloat Values[MaxChannels][HRIR_LENGTH][2];
|
||||
ALuint Offset;
|
||||
} HrtfState;
|
||||
|
||||
typedef struct HrtfParams {
|
||||
ALfloat Gain;
|
||||
ALfloat Dir[3];
|
||||
ALIGN(16) ALfloat Coeffs[MaxChannels][HRIR_LENGTH][2];
|
||||
ALIGN(16) ALfloat CoeffStep[HRIR_LENGTH][2];
|
||||
ALuint Delay[MaxChannels][2];
|
||||
ALint DelayStep[2];
|
||||
ALuint IrSize;
|
||||
} HrtfParams;
|
||||
|
||||
typedef struct DirectParams {
|
||||
ALfloat (*OutBuffer)[BUFFERSIZE];
|
||||
ALfloat *ClickRemoval;
|
||||
ALfloat *PendingClicks;
|
||||
|
||||
struct {
|
||||
HrtfParams Params;
|
||||
HrtfState *State;
|
||||
} Hrtf;
|
||||
|
||||
/* 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. FrontLeft). Not used with HRTF. */
|
||||
ALfloat Gains[MaxChannels][MaxChannels];
|
||||
|
||||
/* A low-pass filter, using 2 chained one-pole filters. */
|
||||
FILTER iirFilter;
|
||||
ALfloat history[MaxChannels*2];
|
||||
} DirectParams;
|
||||
|
||||
typedef struct SendParams {
|
||||
struct ALeffectslot *Slot;
|
||||
|
||||
/* Gain control, which applies to all input channels to a single (mono)
|
||||
* output buffer. */
|
||||
ALfloat Gain;
|
||||
|
||||
/* A low-pass filter, using 2 chained one-pole filters. */
|
||||
FILTER iirFilter;
|
||||
ALfloat history[MaxChannels*2];
|
||||
} SendParams;
|
||||
|
||||
|
||||
typedef struct ALsource
|
||||
{
|
||||
/** Source properties. */
|
||||
volatile ALfloat Pitch;
|
||||
volatile ALfloat Gain;
|
||||
volatile ALfloat OuterGain;
|
||||
volatile ALfloat MinGain;
|
||||
volatile ALfloat MaxGain;
|
||||
volatile ALfloat InnerAngle;
|
||||
volatile ALfloat OuterAngle;
|
||||
volatile ALfloat RefDistance;
|
||||
volatile ALfloat MaxDistance;
|
||||
volatile ALfloat RollOffFactor;
|
||||
volatile ALfloat Position[3];
|
||||
volatile ALfloat Velocity[3];
|
||||
volatile ALfloat Orientation[3];
|
||||
volatile ALboolean HeadRelative;
|
||||
volatile ALboolean Looping;
|
||||
volatile enum DistanceModel DistanceModel;
|
||||
volatile ALboolean DirectChannels;
|
||||
|
||||
volatile ALboolean DryGainHFAuto;
|
||||
volatile ALboolean WetGainAuto;
|
||||
volatile ALboolean WetGainHFAuto;
|
||||
volatile ALfloat OuterGainHF;
|
||||
|
||||
volatile ALfloat AirAbsorptionFactor;
|
||||
volatile ALfloat RoomRolloffFactor;
|
||||
volatile ALfloat DopplerFactor;
|
||||
|
||||
enum Resampler Resampler;
|
||||
|
||||
/**
|
||||
* Last user-specified offset, and the offset type (bytes, samples, or
|
||||
* seconds).
|
||||
*/
|
||||
ALdouble Offset;
|
||||
ALenum OffsetType;
|
||||
|
||||
/** Source type (static, streaming, or undetermined) */
|
||||
volatile ALint SourceType;
|
||||
|
||||
/** Source state (initial, playing, paused, or stopped) */
|
||||
volatile ALenum state;
|
||||
ALenum new_state;
|
||||
|
||||
/**
|
||||
* Source offset in samples, relative to the currently playing buffer, NOT
|
||||
* the whole queue, and the fractional (fixed-point) offset to the next
|
||||
* sample.
|
||||
*/
|
||||
ALuint position;
|
||||
ALuint position_fraction;
|
||||
|
||||
/** Source Buffer Queue info. */
|
||||
ALbufferlistitem *queue;
|
||||
ALuint BuffersInQueue;
|
||||
ALuint BuffersPlayed;
|
||||
|
||||
/** Current buffer sample info. */
|
||||
ALuint NumChannels;
|
||||
ALuint SampleSize;
|
||||
|
||||
/** Direct filter and auxiliary send info. */
|
||||
ALfloat DirectGain;
|
||||
ALfloat DirectGainHF;
|
||||
|
||||
struct {
|
||||
struct ALeffectslot *Slot;
|
||||
ALfloat Gain;
|
||||
ALfloat GainHF;
|
||||
} Send[MAX_SENDS];
|
||||
|
||||
/** HRTF info. */
|
||||
HrtfState Hrtf;
|
||||
|
||||
/** Current target parameters used for mixing. */
|
||||
struct {
|
||||
ResamplerFunc Resample;
|
||||
DryMixerFunc DryMix;
|
||||
WetMixerFunc WetMix;
|
||||
|
||||
ALint Step;
|
||||
|
||||
DirectParams Direct;
|
||||
|
||||
SendParams Send[MAX_SENDS];
|
||||
} Params;
|
||||
/** Source needs to update its mixing parameters. */
|
||||
volatile ALenum NeedsUpdate;
|
||||
|
||||
/** Method to update mixing parameters. */
|
||||
ALvoid (*Update)(struct ALsource *self, const ALCcontext *context);
|
||||
|
||||
/** Self ID */
|
||||
ALuint id;
|
||||
} 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,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,127 @@
|
||||
#ifndef _ALU_H_
|
||||
#define _ALU_H_
|
||||
|
||||
#include "alMain.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 */
|
||||
|
||||
#ifndef FLT_EPSILON
|
||||
#define FLT_EPSILON (1.19209290e-07f)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ALsource;
|
||||
struct ALbuffer;
|
||||
struct DirectParams;
|
||||
struct SendParams;
|
||||
|
||||
typedef void (*ResamplerFunc)(const ALfloat *src, ALuint frac, ALuint increment,
|
||||
ALfloat *RESTRICT dst, ALuint dstlen);
|
||||
|
||||
typedef ALvoid (*DryMixerFunc)(const struct DirectParams *params,
|
||||
const ALfloat *RESTRICT data, ALuint srcchan,
|
||||
ALuint OutPos, ALuint SamplesToDo,
|
||||
ALuint BufferSize);
|
||||
typedef ALvoid (*WetMixerFunc)(const struct SendParams *params,
|
||||
const ALfloat *RESTRICT data,
|
||||
ALuint OutPos, ALuint SamplesToDo,
|
||||
ALuint BufferSize);
|
||||
|
||||
|
||||
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
|
||||
#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */
|
||||
|
||||
#define FRACTIONBITS (14)
|
||||
#define FRACTIONONE (1<<FRACTIONBITS)
|
||||
#define FRACTIONMASK (FRACTIONONE-1)
|
||||
|
||||
|
||||
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 ALuint64 minu64(ALuint64 a, ALuint64 b)
|
||||
{ return ((a > b) ? b : a); }
|
||||
static __inline ALuint64 maxu64(ALuint64 a, ALuint64 b)
|
||||
{ return ((a > b) ? a : b); }
|
||||
static __inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max)
|
||||
{ return minu64(max, maxu64(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;
|
||||
}
|
||||
|
||||
|
||||
ALvoid aluInitPanning(ALCdevice *Device);
|
||||
|
||||
ALvoid ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, ALfloat ingain, ALfloat *gains);
|
||||
|
||||
ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
|
||||
ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
|
||||
|
||||
ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo);
|
||||
|
||||
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
|
||||
/* Caller must lock the device. */
|
||||
ALvoid aluHandleDisconnect(ALCdevice *device);
|
||||
|
||||
extern ALfloat ConeScale;
|
||||
extern ALfloat ZScale;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*-
|
||||
* 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);
|
||||
|
||||
/* 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,609 @@
|
||||
/**
|
||||
* 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 ALenum AddEffectSlotArray(ALCcontext *Context, ALsizei count, const ALuint *slots);
|
||||
static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *slot);
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsizei cur = 0;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
ALenum err;
|
||||
|
||||
CHECK_VALUE(Context, n >= 0);
|
||||
for(cur = 0;cur < n;cur++)
|
||||
{
|
||||
ALeffectslot *slot = al_calloc(16, sizeof(ALeffectslot));
|
||||
err = AL_OUT_OF_MEMORY;
|
||||
if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR)
|
||||
{
|
||||
al_free(slot);
|
||||
al_throwerr(Context, err);
|
||||
break;
|
||||
}
|
||||
|
||||
err = NewThunkEntry(&slot->id);
|
||||
if(err == AL_NO_ERROR)
|
||||
err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->id, slot);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
FreeThunkEntry(slot->id);
|
||||
ALeffectState_Destroy(slot->EffectState);
|
||||
al_free(slot);
|
||||
|
||||
al_throwerr(Context, err);
|
||||
}
|
||||
|
||||
effectslots[cur] = slot->id;
|
||||
}
|
||||
err = AddEffectSlotArray(Context, n, effectslots);
|
||||
if(err != AL_NO_ERROR)
|
||||
al_throwerr(Context, err);
|
||||
}
|
||||
al_catchany()
|
||||
{
|
||||
if(cur > 0)
|
||||
alDeleteAuxiliaryEffectSlots(cur, effectslots);
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot *slot;
|
||||
ALsizei i;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, n >= 0);
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
if((slot=LookupEffectSlot(Context, effectslots[i])) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
if(slot->ref != 0)
|
||||
al_throwerr(Context, AL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// All effectslots are valid
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
if((slot=RemoveEffectSlot(Context, effectslots[i])) == NULL)
|
||||
continue;
|
||||
FreeThunkEntry(slot->id);
|
||||
|
||||
RemoveEffectSlotArray(Context, slot);
|
||||
ALeffectState_Destroy(slot->EffectState);
|
||||
|
||||
memset(slot, 0, sizeof(*slot));
|
||||
al_free(slot);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
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 value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot *Slot;
|
||||
ALeffect *effect = NULL;
|
||||
ALenum err;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
if((Slot=LookupEffectSlot(Context, effectslot)) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
CHECK_VALUE(Context, value == 0 || (effect=LookupEffect(device, value)) != NULL);
|
||||
|
||||
err = InitializeEffect(device, Slot, effect);
|
||||
if(err != AL_NO_ERROR)
|
||||
al_throwerr(Context, err);
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
CHECK_VALUE(Context, value == AL_TRUE || value == AL_FALSE);
|
||||
|
||||
Slot->AuxSendAuto = value;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
alAuxiliaryEffectSloti(effectslot, param, values[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
if(LookupEffectSlot(Context, effectslot) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot *Slot;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
if((Slot=LookupEffectSlot(Context, effectslot)) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
CHECK_VALUE(Context, value >= 0.0f && value <= 1.0f);
|
||||
|
||||
Slot->Gain = value;
|
||||
Slot->NeedsUpdate = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
alAuxiliaryEffectSlotf(effectslot, param, values[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
if(LookupEffectSlot(Context, effectslot) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot *Slot;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
if((Slot=LookupEffectSlot(Context, effectslot)) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
*value = Slot->effect.id;
|
||||
break;
|
||||
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
*value = Slot->AuxSendAuto;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
alGetAuxiliaryEffectSloti(effectslot, param, values);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
if(LookupEffectSlot(Context, effectslot) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot *Slot;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
if((Slot=LookupEffectSlot(Context, effectslot)) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
*value = Slot->Gain;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
alGetAuxiliaryEffectSlotf(effectslot, param, values);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
if(LookupEffectSlot(Context, effectslot) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
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, ALCdevice *Device, const ALeffectslot *Slot)
|
||||
{
|
||||
(void)State;
|
||||
(void)Device;
|
||||
(void)Slot;
|
||||
}
|
||||
static ALvoid NoneProcess(ALeffectState *State, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE])
|
||||
{
|
||||
(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 AddEffectSlotArray(ALCcontext *Context, ALsizei count, const ALuint *slots)
|
||||
{
|
||||
ALsizei i;
|
||||
|
||||
LockContext(Context);
|
||||
if(count > Context->MaxActiveEffectSlots-Context->ActiveEffectSlotCount)
|
||||
{
|
||||
ALsizei newcount;
|
||||
void *temp = NULL;
|
||||
|
||||
newcount = Context->MaxActiveEffectSlots ? (Context->MaxActiveEffectSlots<<1) : 1;
|
||||
if(newcount > Context->MaxActiveEffectSlots)
|
||||
temp = realloc(Context->ActiveEffectSlots,
|
||||
newcount * sizeof(*Context->ActiveEffectSlots));
|
||||
if(!temp)
|
||||
{
|
||||
UnlockContext(Context);
|
||||
return AL_OUT_OF_MEMORY;
|
||||
}
|
||||
Context->ActiveEffectSlots = temp;
|
||||
Context->MaxActiveEffectSlots = newcount;
|
||||
}
|
||||
for(i = 0;i < count;i++)
|
||||
{
|
||||
ALeffectslot *slot = LookupEffectSlot(Context, slots[i]);
|
||||
assert(slot != NULL);
|
||||
Context->ActiveEffectSlots[Context->ActiveEffectSlotCount++] = slot;
|
||||
}
|
||||
UnlockContext(Context);
|
||||
return AL_NO_ERROR;
|
||||
}
|
||||
|
||||
ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect)
|
||||
{
|
||||
ALenum newtype = (effect ? effect->type : AL_EFFECT_NULL);
|
||||
ALeffectState *State = NULL;
|
||||
ALenum err = AL_NO_ERROR;
|
||||
|
||||
ALCdevice_Lock(Device);
|
||||
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)
|
||||
{
|
||||
ALCdevice_Unlock(Device);
|
||||
return err;
|
||||
}
|
||||
|
||||
if(State)
|
||||
{
|
||||
FPUCtl oldMode;
|
||||
SetMixerFPUMode(&oldMode);
|
||||
|
||||
if(ALeffectState_DeviceUpdate(State, Device) == AL_FALSE)
|
||||
{
|
||||
RestoreFPUMode(&oldMode);
|
||||
ALCdevice_Unlock(Device);
|
||||
ALeffectState_Destroy(State);
|
||||
return AL_OUT_OF_MEMORY;
|
||||
}
|
||||
State = ExchangePtr((XchgPtr*)&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, Device, EffectSlot);
|
||||
ALCdevice_Unlock(Device);
|
||||
|
||||
RestoreFPUMode(&oldMode);
|
||||
|
||||
ALeffectState_Destroy(State);
|
||||
State = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!effect)
|
||||
memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect));
|
||||
else
|
||||
memcpy(&EffectSlot->effect, effect, sizeof(*effect));
|
||||
ALCdevice_Unlock(Device);
|
||||
EffectSlot->NeedsUpdate = AL_TRUE;
|
||||
}
|
||||
|
||||
return AL_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
ALenum InitEffectSlot(ALeffectslot *slot)
|
||||
{
|
||||
ALint i, c;
|
||||
|
||||
if(!(slot->EffectState=NoneCreate()))
|
||||
return AL_OUT_OF_MEMORY;
|
||||
|
||||
slot->Gain = 1.0;
|
||||
slot->AuxSendAuto = AL_TRUE;
|
||||
slot->NeedsUpdate = AL_FALSE;
|
||||
for(c = 0;c < 1;c++)
|
||||
{
|
||||
for(i = 0;i < BUFFERSIZE;i++)
|
||||
slot->WetBuffer[c][i] = 0.0f;
|
||||
slot->ClickRemoval[c] = 0.0f;
|
||||
slot->PendingClicks[c] = 0.0f;
|
||||
}
|
||||
slot->ref = 0;
|
||||
|
||||
return AL_NO_ERROR;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
ALeffectState_Destroy(temp->EffectState);
|
||||
|
||||
FreeThunkEntry(temp->id);
|
||||
memset(temp, 0, sizeof(ALeffectslot));
|
||||
al_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,71 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
AL_API ALenum AL_APIENTRY alGetError(void)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALenum errorCode;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context)
|
||||
{
|
||||
if(TrapALError)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if(IsDebuggerPresent())
|
||||
DebugBreak();
|
||||
#elif defined(SIGTRAP)
|
||||
raise(SIGTRAP);
|
||||
#endif
|
||||
}
|
||||
return AL_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR);
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* 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"
|
||||
|
||||
|
||||
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 ret = AL_FALSE;
|
||||
ALCcontext *Context;
|
||||
const char *ptr;
|
||||
size_t len;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return AL_FALSE;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, extName);
|
||||
|
||||
len = strlen(extName);
|
||||
ptr = Context->ExtensionList;
|
||||
while(ptr && *ptr)
|
||||
{
|
||||
if(strncasecmp(ptr, extName, len) == 0 &&
|
||||
(ptr[len] == '\0' || isspace(ptr[len])))
|
||||
{
|
||||
ret = AL_TRUE;
|
||||
break;
|
||||
}
|
||||
if((ptr=strchr(ptr, ' ')) != NULL)
|
||||
{
|
||||
do {
|
||||
++ptr;
|
||||
} while(isspace(*ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
if(!enumName)
|
||||
return (ALenum)0;
|
||||
return alcGetEnumValue(NULL, enumName);
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
/**
|
||||
* 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 "alu.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 cur = 0;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
ALenum err;
|
||||
|
||||
CHECK_VALUE(Context, n >= 0);
|
||||
for(cur = 0;cur < n;cur++)
|
||||
{
|
||||
ALfilter *filter = calloc(1, sizeof(ALfilter));
|
||||
if(!filter)
|
||||
al_throwerr(Context, AL_OUT_OF_MEMORY);
|
||||
InitFilterParams(filter, AL_FILTER_NULL);
|
||||
|
||||
err = NewThunkEntry(&filter->id);
|
||||
if(err == AL_NO_ERROR)
|
||||
err = InsertUIntMapEntry(&device->FilterMap, filter->id, filter);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
FreeThunkEntry(filter->id);
|
||||
memset(filter, 0, sizeof(ALfilter));
|
||||
free(filter);
|
||||
|
||||
al_throwerr(Context, err);
|
||||
}
|
||||
|
||||
filters[cur] = filter->id;
|
||||
}
|
||||
}
|
||||
al_catchany()
|
||||
{
|
||||
if(cur > 0)
|
||||
alDeleteFilters(cur, filters);
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALfilter *Filter;
|
||||
ALsizei i;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
CHECK_VALUE(Context, n >= 0);
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
if(filters[i] && LookupFilter(device, filters[i]) == NULL)
|
||||
al_throwerr(Context, AL_INVALID_NAME);
|
||||
}
|
||||
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
if((Filter=RemoveFilter(device, filters[i])) == NULL)
|
||||
continue;
|
||||
FreeThunkEntry(Filter->id);
|
||||
|
||||
memset(Filter, 0, sizeof(*Filter));
|
||||
free(Filter);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
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 value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
if(param == AL_FILTER_TYPE)
|
||||
{
|
||||
if(value == AL_FILTER_NULL || value == AL_FILTER_LOWPASS)
|
||||
InitFilterParams(ALFilter, value);
|
||||
else
|
||||
alSetError(Context, AL_INVALID_VALUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_SetParami(ALFilter, Context, param, value);
|
||||
}
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
alFilteri(filter, param, values[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_SetParamiv(ALFilter, Context, param, values);
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_SetParamf(ALFilter, Context, param, value);
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_SetParamfv(ALFilter, Context, param, values);
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
if(param == AL_FILTER_TYPE)
|
||||
*value = ALFilter->type;
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_GetParami(ALFilter, Context, param, value);
|
||||
}
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
alGetFilteri(filter, param, values);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_GetParamiv(ALFilter, Context, param, values);
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_GetParamf(ALFilter, Context, param, value);
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCdevice *Device;
|
||||
ALfilter *ALFilter;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
Device = Context->Device;
|
||||
if((ALFilter=LookupFilter(Device, filter)) == NULL)
|
||||
alSetError(Context, AL_INVALID_NAME);
|
||||
else
|
||||
{
|
||||
/* Call the appropriate handler */
|
||||
ALfilter_GetParamfv(ALFilter, Context, param, values);
|
||||
}
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
ALfloat lpCoeffCalc(ALfloat g, ALfloat cw)
|
||||
{
|
||||
ALfloat a = 0.0f;
|
||||
|
||||
if(g < 0.9999f) /* 1-epsilon */
|
||||
{
|
||||
/* Be careful with gains < 0.001, as that causes the coefficient head
|
||||
* towards 1, which will flatten the signal */
|
||||
g = maxf(g, 0.001f);
|
||||
a = (1 - g*cw - sqrtf(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->id);
|
||||
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,472 @@
|
||||
/**
|
||||
* 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 param, ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_GAIN:
|
||||
CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
|
||||
|
||||
Context->Listener->Gain = value;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
|
||||
|
||||
Context->Listener->MetersPerUnit = value;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_POSITION:
|
||||
CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));
|
||||
|
||||
LockContext(Context);
|
||||
Context->Listener->Position[0] = value1;
|
||||
Context->Listener->Position[1] = value2;
|
||||
Context->Listener->Position[2] = value3;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
case AL_VELOCITY:
|
||||
CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));
|
||||
|
||||
LockContext(Context);
|
||||
Context->Listener->Velocity[0] = value1;
|
||||
Context->Listener->Velocity[1] = value2;
|
||||
Context->Listener->Velocity[2] = value3;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
if(values)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_GAIN:
|
||||
case AL_METERS_PER_UNIT:
|
||||
alListenerf(param, values[0]);
|
||||
return;
|
||||
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
alListener3f(param, values[0], values[1], values[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(param)
|
||||
{
|
||||
case AL_ORIENTATION:
|
||||
CHECK_VALUE(Context, isfinite(values[0]) && isfinite(values[1]) &&
|
||||
isfinite(values[2]) && isfinite(values[3]) &&
|
||||
isfinite(values[4]) && isfinite(values[5]));
|
||||
|
||||
LockContext(Context);
|
||||
/* AT then UP */
|
||||
Context->Listener->Forward[0] = values[0];
|
||||
Context->Listener->Forward[1] = values[1];
|
||||
Context->Listener->Forward[2] = values[2];
|
||||
Context->Listener->Up[0] = values[3];
|
||||
Context->Listener->Up[1] = values[4];
|
||||
Context->Listener->Up[2] = values[5];
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alListeneri(ALenum param, ALint value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
(void)value;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
alListener3f(param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
if(values)
|
||||
{
|
||||
ALfloat fvals[6];
|
||||
switch(param)
|
||||
{
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
alListener3f(param, (ALfloat)values[0], (ALfloat)values[1], (ALfloat)values[2]);
|
||||
return;
|
||||
|
||||
case AL_ORIENTATION:
|
||||
fvals[0] = (ALfloat)values[0];
|
||||
fvals[1] = (ALfloat)values[1];
|
||||
fvals[2] = (ALfloat)values[2];
|
||||
fvals[3] = (ALfloat)values[3];
|
||||
fvals[4] = (ALfloat)values[4];
|
||||
fvals[5] = (ALfloat)values[5];
|
||||
alListenerfv(param, fvals);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value);
|
||||
switch(param)
|
||||
{
|
||||
case AL_GAIN:
|
||||
*value = Context->Listener->Gain;
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
*value = Context->Listener->MetersPerUnit;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value1 && value2 && value3);
|
||||
switch(param)
|
||||
{
|
||||
case AL_POSITION:
|
||||
LockContext(Context);
|
||||
*value1 = Context->Listener->Position[0];
|
||||
*value2 = Context->Listener->Position[1];
|
||||
*value3 = Context->Listener->Position[2];
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
case AL_VELOCITY:
|
||||
LockContext(Context);
|
||||
*value1 = Context->Listener->Velocity[0];
|
||||
*value2 = Context->Listener->Velocity[1];
|
||||
*value3 = Context->Listener->Velocity[2];
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_GAIN:
|
||||
case AL_METERS_PER_UNIT:
|
||||
alGetListenerf(param, values);
|
||||
return;
|
||||
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
alGetListener3f(param, values+0, values+1, values+2);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(param)
|
||||
{
|
||||
case AL_ORIENTATION:
|
||||
LockContext(Context);
|
||||
// AT then UP
|
||||
values[0] = Context->Listener->Forward[0];
|
||||
values[1] = Context->Listener->Forward[1];
|
||||
values[2] = Context->Listener->Forward[2];
|
||||
values[3] = Context->Listener->Up[0];
|
||||
values[4] = Context->Listener->Up[1];
|
||||
values[5] = Context->Listener->Up[2];
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum param, ALint *value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value);
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value1 && value2 && value3);
|
||||
switch (param)
|
||||
{
|
||||
case AL_POSITION:
|
||||
LockContext(Context);
|
||||
*value1 = (ALint)Context->Listener->Position[0];
|
||||
*value2 = (ALint)Context->Listener->Position[1];
|
||||
*value3 = (ALint)Context->Listener->Position[2];
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
case AL_VELOCITY:
|
||||
LockContext(Context);
|
||||
*value1 = (ALint)Context->Listener->Velocity[0];
|
||||
*value2 = (ALint)Context->Listener->Velocity[1];
|
||||
*value3 = (ALint)Context->Listener->Velocity[2];
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
|
||||
AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint* values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
alGetListener3i(param, values+0, values+1, values+2);
|
||||
return;
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(param)
|
||||
{
|
||||
case AL_ORIENTATION:
|
||||
LockContext(Context);
|
||||
// AT then UP
|
||||
values[0] = (ALint)Context->Listener->Forward[0];
|
||||
values[1] = (ALint)Context->Listener->Forward[1];
|
||||
values[2] = (ALint)Context->Listener->Forward[2];
|
||||
values[3] = (ALint)Context->Listener->Up[0];
|
||||
values[4] = (ALint)Context->Listener->Up[1];
|
||||
values[5] = (ALint)Context->Listener->Up[2];
|
||||
UnlockContext(Context);
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,674 @@
|
||||
/**
|
||||
* 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"
|
||||
|
||||
|
||||
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;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
Context->SourceDistanceModel = AL_TRUE;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
Context->SourceDistanceModel = AL_FALSE;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALboolean value=AL_FALSE;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return AL_FALSE;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
value = Context->SourceDistanceModel;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
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;
|
||||
|
||||
al_try
|
||||
{
|
||||
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->SpeedOfSound != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
value = Context->DeferUpdates;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
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;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = (ALdouble)Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = (ALdouble)Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (ALdouble)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = (ALdouble)Context->SpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
value = (ALdouble)Context->DeferUpdates;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
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;
|
||||
|
||||
al_try
|
||||
{
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (ALfloat)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = Context->SpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
value = (ALfloat)Context->DeferUpdates;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALint value = 0;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return 0;
|
||||
|
||||
al_try
|
||||
{
|
||||
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->SpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
value = (ALint)Context->DeferUpdates;
|
||||
break;
|
||||
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname, ALboolean *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
if(values)
|
||||
{
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
case AL_DISTANCE_MODEL:
|
||||
case AL_SPEED_OF_SOUND:
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
values[0] = alGetBoolean(pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(pname)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname, ALdouble *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
if(values)
|
||||
{
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
case AL_DISTANCE_MODEL:
|
||||
case AL_SPEED_OF_SOUND:
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
values[0] = alGetDouble(pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(pname)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname, ALfloat *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
if(values)
|
||||
{
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
case AL_DISTANCE_MODEL:
|
||||
case AL_SPEED_OF_SOUND:
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
values[0] = alGetFloat(pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(pname)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname, ALint *values)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
if(values)
|
||||
{
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
case AL_DISTANCE_MODEL:
|
||||
case AL_SPEED_OF_SOUND:
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
values[0] = alGetInteger(pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, values);
|
||||
switch(pname)
|
||||
{
|
||||
default:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname)
|
||||
{
|
||||
const ALchar *value;
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return NULL;
|
||||
|
||||
al_try
|
||||
{
|
||||
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:
|
||||
al_throwerr(Context, AL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
al_catchany()
|
||||
{
|
||||
value = NULL;
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
|
||||
|
||||
Context->DopplerFactor = value;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
|
||||
|
||||
Context->DopplerVelocity = value;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value > 0.0f && isfinite(value));
|
||||
|
||||
Context->SpeedOfSound = value;
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
ALCcontext_DecRef(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextRef();
|
||||
if(!Context) return;
|
||||
|
||||
al_try
|
||||
{
|
||||
CHECK_VALUE(Context, value == AL_NONE ||
|
||||
value == AL_INVERSE_DISTANCE ||
|
||||
value == AL_INVERSE_DISTANCE_CLAMPED ||
|
||||
value == AL_LINEAR_DISTANCE ||
|
||||
value == AL_LINEAR_DISTANCE_CLAMPED ||
|
||||
value == AL_EXPONENT_DISTANCE ||
|
||||
value == AL_EXPONENT_DISTANCE_CLAMPED);
|
||||
|
||||
Context->DistanceModel = value;
|
||||
if(!Context->SourceDistanceModel)
|
||||
Context->UpdateSources = AL_TRUE;
|
||||
}
|
||||
al_endtry;
|
||||
|
||||
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;
|
||||
FPUCtl oldMode;
|
||||
|
||||
SetMixerFPUMode(&oldMode);
|
||||
|
||||
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->Device, *slot);
|
||||
slot++;
|
||||
}
|
||||
|
||||
UnlockContext(Context);
|
||||
RestoreFPUMode(&oldMode);
|
||||
}
|
||||
|
||||
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->Offset >= 0.0)
|
||||
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 entries!\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);
|
||||
}
|
||||
Reference in New Issue
Block a user