18 #ifndef AL_SOFT_deferred_updates
19 #define AL_SOFT_deferred_updates 1
20 #define AL_DEFERRED_UPDATES_SOFT 0xC002
23 #ifdef AL_ALEXT_PROTOTYPES
30 #if defined(HAVE_STDINT_H)
34 #elif defined(HAVE___INT64)
35 typedef __int64 ALint64;
36 typedef unsigned __int64 ALuint64;
37 #elif (SIZEOF_LONG == 8)
39 typedef unsigned long ALuint64;
40 #elif (SIZEOF_LONG_LONG == 8)
41 typedef long long ALint64;
42 typedef unsigned long long ALuint64;
48 #define MAKEU64(x,y) (((ALuint64)(x)<<32)|(ALuint64)(y))
50 #ifdef HAVE_GCC_FORMAT
51 #define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
53 #define PRINTF_STYLE(x, y)
61 #define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
63 #define COUNTOF(x) (sizeof((x))/sizeof((x)[0]))
67 #define WIN32_LEAN_AND_MEAN
70 typedef DWORD pthread_key_t;
71 int pthread_key_create(pthread_key_t *key,
void (*callback)(
void*));
72 int pthread_key_delete(pthread_key_t key);
73 void *pthread_getspecific(pthread_key_t key);
74 int pthread_setspecific(pthread_key_t key,
void *
val);
76 #define HAVE_DYNLOAD 1
77 void *LoadLib(
const char *
name);
78 void CloseLib(
void *
handle);
79 void *GetSymbol(
void *
handle,
const char *
name);
81 WCHAR *strdupW(
const WCHAR *
str);
83 typedef LONG pthread_once_t;
84 #define PTHREAD_ONCE_INIT 0
85 void pthread_once(pthread_once_t *once,
void (*callback)(
void));
87 static __inline
int sched_yield(
void)
88 { SwitchToThread();
return 0; }
99 #define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0)
110 #if defined(HAVE_DLFCN_H)
111 #define HAVE_DYNLOAD 1
112 void *LoadLib(
const char *
name);
113 void CloseLib(
void *
handle);
114 void *GetSymbol(
void *
handle,
const char *
name);
121 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
123 static __inline RefCount IncrementRef(
volatile RefCount *ptr)
124 {
return __sync_add_and_fetch(ptr, 1); }
125 static __inline RefCount DecrementRef(
volatile RefCount *ptr)
126 {
return __sync_sub_and_fetch(ptr, 1); }
128 static __inline
int ExchangeInt(
volatile int *ptr,
int newval)
130 return __sync_lock_test_and_set(ptr, newval);
132 static __inline
void *ExchangePtr(XchgPtr *ptr,
void *newval)
134 return __sync_lock_test_and_set(ptr, newval);
136 static __inline
ALboolean CompExchangeInt(
volatile int *ptr,
int oldval,
int newval)
138 return __sync_bool_compare_and_swap(ptr, oldval, newval);
140 static __inline
ALboolean CompExchangePtr(XchgPtr *ptr,
void *oldval,
void *newval)
142 return __sync_bool_compare_and_swap(ptr, oldval, newval);
145 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
147 static __inline
int xaddl(
volatile int *dest,
int incr)
150 __asm__ __volatile__(
"lock; xaddl %0,(%1)"
152 :
"r" (dest),
"0" (incr)
158 static __inline RefCount IncrementRef(
volatile RefCount *ptr)
159 {
return xaddl(ptr, 1)+1; }
160 static __inline RefCount DecrementRef(
volatile RefCount *ptr)
161 {
return xaddl(ptr, -1)-1; }
163 static __inline
int ExchangeInt(
volatile int *dest,
int newval)
166 __asm__ __volatile__(
"lock; xchgl %0,(%1)"
168 :
"r" (dest),
"0" (newval)
173 static __inline
ALboolean CompExchangeInt(
volatile int *dest,
int oldval,
int newval)
176 __asm__ __volatile__(
"lock; cmpxchgl %2,(%1)"
178 :
"r" (dest),
"r" (newval),
"0" (oldval)
180 return ret == oldval;
183 static __inline
void *ExchangePtr(XchgPtr *dest,
void *newval)
186 __asm__ __volatile__(
188 "lock; xchgl %0,(%1)"
190 "lock; xchgq %0,(%1)"
193 :
"r" (dest),
"0" (newval)
199 static __inline
ALboolean CompExchangePtr(XchgPtr *dest,
void *oldval,
void *newval)
202 __asm__ __volatile__(
204 "lock; cmpxchgl %2,(%1)"
206 "lock; cmpxchgq %2,(%1)"
209 :
"r" (dest),
"r" (newval),
"0" (oldval)
212 return ret == oldval;
215 #elif defined(_WIN32)
218 static __inline RefCount IncrementRef(
volatile RefCount *ptr)
219 {
return InterlockedIncrement(ptr); }
220 static __inline RefCount DecrementRef(
volatile RefCount *ptr)
221 {
return InterlockedDecrement(ptr); }
223 extern ALbyte LONG_size_does_not_match_int[(
sizeof(LONG)==
sizeof(
int))?1:-1];
225 static __inline
int ExchangeInt(
volatile int *ptr,
int newval)
231 return InterlockedExchange(
u.l, newval);
233 static __inline
void *ExchangePtr(XchgPtr *ptr,
void *newval)
235 return InterlockedExchangePointer(ptr, newval);
237 static __inline
ALboolean CompExchangeInt(
volatile int *ptr,
int oldval,
int newval)
243 return InterlockedCompareExchange(
u.l, newval, oldval) == oldval;
245 static __inline
ALboolean CompExchangePtr(XchgPtr *ptr,
void *oldval,
void *newval)
247 return InterlockedCompareExchangePointer(ptr, newval, oldval) == oldval;
250 #elif defined(__APPLE__)
252 #include <libkern/OSAtomic.h>
255 static __inline RefCount IncrementRef(
volatile RefCount *ptr)
256 {
return OSAtomicIncrement32Barrier(ptr); }
257 static __inline RefCount DecrementRef(
volatile RefCount *ptr)
258 {
return OSAtomicDecrement32Barrier(ptr); }
260 static __inline
int ExchangeInt(
volatile int *ptr,
int newval)
266 }
while(!OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr));
269 static __inline
void *ExchangePtr(XchgPtr *ptr,
void *newval)
274 }
while(!OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr));
277 static __inline
ALboolean CompExchangeInt(
volatile int *ptr,
int oldval,
int newval)
279 return OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr);
281 static __inline
ALboolean CompExchangePtr(XchgPtr *ptr,
void *oldval,
void *newval)
283 return OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr);
287 #error "No atomic functions available on this platform!"
342 #define DEFAULT_OUTPUT_RATE (44100)
343 #define MIN_OUTPUT_RATE (8000)
367 #elif defined(_MSC_VER) && defined(_M_IX86)
556 #define BUFFERSIZE 2048
635 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
636 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
637 #define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
638 #define ALCdevice_StartPlayback(a) ((a)->Funcs->StartPlayback((a)))
639 #define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
640 #define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
641 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
642 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
643 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
644 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
645 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
646 #define ALCdevice_Lock(a) ((a)->Funcs->Lock((a)))
647 #define ALCdevice_Unlock(a) ((a)->Funcs->Unlock((a)))
648 #define ALCdevice_GetLatency(a) ((a)->Funcs->GetLatency((a)))
651 #define DEVICE_FREQUENCY_REQUEST (1<<1)
653 #define DEVICE_CHANNELS_REQUEST (1<<2)
655 #define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
658 #define DEVICE_WIDE_STEREO (1<<16)
661 #define DEVICE_RUNNING (1<<31)
664 #define INVALID_OFFSET (~0u)
667 #define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k)))
668 #define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k)))
669 #define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k)))
670 #define RemoveBuffer(m, k) ((struct ALbuffer*)RemoveUIntMapKey(&(m)->BufferMap, (k)))
671 #define RemoveEffect(m, k) ((struct ALeffect*)RemoveUIntMapKey(&(m)->EffectMap, (k)))
672 #define RemoveFilter(m, k) ((struct ALfilter*)RemoveUIntMapKey(&(m)->FilterMap, (k)))
710 #define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k)))
711 #define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k)))
712 #define RemoveSource(m, k) ((struct ALsource*)RemoveUIntMapKey(&(m)->SourceMap, (k)))
713 #define RemoveEffectSlot(m, k) ((struct ALeffectslot*)RemoveUIntMapKey(&(m)->EffectSlotMap, (k)))
760 const char *
GetConfigValue(
const char *blockName,
const char *keyName,
const char *def);
762 int ConfigValueStr(
const char *blockName,
const char *keyName,
const char **ret);
763 int ConfigValueInt(
const char *blockName,
const char *keyName,
int *ret);
764 int ConfigValueUInt(
const char *blockName,
const char *keyName,
unsigned int *ret);
765 int ConfigValueFloat(
const char *blockName,
const char *keyName,
float *ret);
775 #define HRIR_BITS (7)
776 #define HRIR_LENGTH (1<<HRIR_BITS)
777 #define HRIR_MASK (HRIR_LENGTH-1)
778 #define HRTFDELAY_BITS (20)
779 #define HRTFDELAY_FRACONE (1<<HRTFDELAY_BITS)
780 #define HRTFDELAY_MASK (HRTFDELAY_FRACONE-1)
789 #define AL_PRINT(T, ...) al_print((T), __FUNCTION__, __VA_ARGS__)
801 #define TRACEREF(...) do { \
802 if(LogLevel >= LogRef) \
803 AL_PRINT("(--)", __VA_ARGS__); \
806 #define TRACE(...) do { \
807 if(LogLevel >= LogTrace) \
808 AL_PRINT("(II)", __VA_ARGS__); \
811 #define WARN(...) do { \
812 if(LogLevel >= LogWarning) \
813 AL_PRINT("(WW)", __VA_ARGS__); \
816 #define ERR(...) do { \
817 if(LogLevel >= LogError) \
818 AL_PRINT("(EE)", __VA_ARGS__); \
838 #define al_try do { \
846 #define al_catch(val) else if(_al_err == (val))
851 #define al_catchany() else
853 #define al_endtry } while(0)
860 #define al_throw(e) do { \
862 assert(_al_err != 0); \
863 goto _al_try_label; \
866 #define al_throwerr(ctx, err) do { \
867 alSetError((ctx), (err)); \
875 #define CHECK_VALUE(ctx, cond) do { \
877 al_throwerr((ctx), AL_INVALID_VALUE); \
int ConfigValueStr(const char *blockName, const char *keyName, const char **ret)
static __inline void UnlockUIntMapWrite(UIntMap *map)
volatile ALenum UpdateSources
volatile ALfloat DopplerFactor
struct ALlistener * Listener
void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat(*coeffs)[2], ALuint *delays)
static __inline ALuint NextPowerOf2(ALuint value)
ALCboolean alc_pulse_init(BackendFuncs *func_list)
GLuint const GLfloat * val
static union @57 EndianTest
#define AL_INVERSE_DISTANCE_CLAMPED
#define ALC_UNSIGNED_SHORT_SOFT
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
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)
struct ALeffectslot * DefaultSlot
int ConfigValueInt(const char *blockName, const char *keyName, int *ret)
ALsizei ActiveEffectSlotCount
struct ALsource ** ActiveSources
struct UIntMap::@59 * array
void alc_pulse_probe(enum DevProbe type)
const ALCchar * DevFmtChannelsString(enum DevFmtChannels chans)
int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret)
ALCboolean alc_loopback_init(BackendFuncs *func_list)
volatile ALfloat SpeedOfSound
ALCboolean(* Init)(BackendFuncs *)
const ALCchar * ExtensionList
void ReadLock(RWLock *lock)
void alc_solaris_probe(enum DevProbe type)
static void Lock(volatile ALenum *l)
void alc_oss_probe(enum DevProbe type)
unsigned long long uint64_t
void alcMMDevApiDeinit(void)
ALCboolean alc_null_init(BackendFuncs *func_list)
ALvoid(AL_APIENTRY * LPALPROCESSUPDATESSOFT)(void)
ALuint GetHrtfIrSize(const struct Hrtf *Hrtf)
ALvoid * LookupUIntMapKey(UIntMap *map, ALuint key)
ALint64 ALCdevice_GetLatencyDefault(ALCdevice *device)
EGLImageKHR EGLint * name
void alc_ca_probe(enum DevProbe type)
ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3])
int ConfigValueExists(const char *blockName, const char *keyName)
void RestoreFPUMode(const FPUCtl *ctl)
ALsizei RingBufferSize(RingBuffer *ring)
void SetDefaultChannelOrder(ALCdevice *device)
void SetMixerFPUMode(FPUCtl *ctl)
ALCcontext * GetContextRef(void)
void alc_loopback_probe(enum DevProbe type)
ALsizei ActiveSourceCount
const char * GetConfigValue(const char *blockName, const char *keyName, const char *def)
void AppendCaptureDeviceList(const ALCchar *name)
void alc_alsa_probe(enum DevProbe type)
#define AL_EXPONENT_DISTANCE
static __inline void LockUIntMapWrite(UIntMap *map)
#define PRINTF_STYLE(x, y)
volatile ALenum write_lock
ALIGN(16) ALfloat SampleData1[BUFFERSIZE+1]
void * al_calloc(size_t alignment, size_t size)
#define ALCdevice_Unlock(a)
void ResetUIntMap(UIntMap *map)
#define ALC_UNSIGNED_BYTE_SOFT
void InitializeCriticalSection(CRITICAL_SECTION *cs)
struct RingBuffer RingBuffer
void alc_loopback_deinit(void)
void InitUIntMap(UIntMap *map, ALsizei limit)
void alc_alsa_deinit(void)
void alcMMDevApiProbe(enum DevProbe type)
#define AL_EXPONENT_DISTANCE_CLAMPED
ALCboolean alc_pa_init(BackendFuncs *func_list)
ALfloat SpeakerAngle[MaxChannels]
ALvoid(AL_APIENTRY * LPALDEFERUPDATESSOFT)(void)
ALuint AuxiliaryEffectSlotMax
ALCboolean alcWinMMInit(BackendFuncs *FuncList)
ALsizei MaxActiveEffectSlots
int GetConfigValueBool(const char *blockName, const char *keyName, int def)
AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
void alc_wave_deinit(void)
ALuint ChannelOffsets[MaxChannels]
void alc_opensl_deinit(void)
enum Channel Speaker2Chan[MaxChannels]
ALuint StopThread(ALvoid *thread)
void al_print(const char *type, const char *func, const char *fmt,...)
void SetDefaultWFXChannelOrder(ALCdevice *device)
ALCboolean alc_ca_init(BackendFuncs *func_list)
void WriteUnlock(RWLock *lock)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
ALCboolean alc_wave_init(BackendFuncs *func_list)
#define AL_INVERSE_DISTANCE
void ReadUnlock(RWLock *lock)
ALCboolean alc_opensl_init(BackendFuncs *func_list)
static __inline ALuint fastf2u(ALfloat f)
void alc_sndio_probe(enum DevProbe type)
RingBuffer * CreateRingBuffer(ALsizei frame_size, ALsizei length)
void alc_pulse_deinit(void)
void alc_oss_deinit(void)
static __inline void UnlockUIntMapRead(UIntMap *map)
void ALCcontext_IncRef(ALCcontext *context)
volatile ALboolean SourceDistanceModel
void alc_null_probe(enum DevProbe type)
volatile ALenum DeferUpdates
ALCboolean alcMMDevApiInit(BackendFuncs *FuncList)
void alc_null_deinit(void)
void alc_opensl_probe(enum DevProbe type)
void FillCPUCaps(ALuint capfilter)
void RWLockInit(RWLock *lock)
ALCboolean alc_alsa_init(BackendFuncs *func_list)
void * al_malloc(size_t alignment, size_t size)
enum DevFmtChannels FmtChans
volatile ALfloat DopplerVelocity
volatile ALenum read_lock
ALCboolean alc_sndio_init(BackendFuncs *func_list)
#define AL_LINEAR_DISTANCE_CLAMPED
pthread_mutex_t CRITICAL_SECTION
static SDL_Thread * thread
void alc_pa_probe(enum DevProbe type)
void EnterCriticalSection(CRITICAL_SECTION *cs)
void ALCdevice_LockDefault(ALCdevice *device)
ALCboolean alc_oss_init(BackendFuncs *func_list)
void DeleteCriticalSection(CRITICAL_SECTION *cs)
void ALCcontext_DecRef(ALCcontext *context)
volatile ALenum read_entry_lock
EGLSurface EGLint void ** value
void alc_sndio_deinit(void)
static void Unlock(volatile ALenum *l)
#define ALC_UNSIGNED_INT_SOFT
ALCcontext *volatile ContextList
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex
AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
static __inline void LockUIntMapRead(UIntMap *map)
int ConfigValueFloat(const char *blockName, const char *keyName, float *ret)
void alcDSoundProbe(enum DevProbe type)
GLdouble GLdouble GLdouble b
ALCcontext *volatile next
ALCboolean alc_solaris_init(BackendFuncs *func_list)
void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len)
void alcWinMMProbe(enum DevProbe type)
ALCboolean alcDSoundInit(BackendFuncs *FuncList)
void(* Probe)(enum DevProbe)
static __inline void LockContext(ALCcontext *context)
EGLImageKHR EGLint EGLint * handle
static __inline ALint fastf2i(ALfloat f)
void alc_wave_probe(enum DevProbe type)
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum map
void LeaveCriticalSection(CRITICAL_SECTION *cs)
const ALCchar * DevFmtTypeString(enum DevFmtType type)
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value)
static __inline void UnlockContext(ALCcontext *context)
ALvoid * RemoveUIntMapKey(UIntMap *map, ALuint key)
volatile ALCenum LastError
void alcDSoundDeinit(void)
struct Hrtf * GetHrtf(ALCdevice *device)
ALuint BytesFromDevFmt(enum DevFmtType type)
volatile RefCount read_count
struct ALeffectslot ** ActiveEffectSlots
void DestroyRingBuffer(RingBuffer *ring)
volatile RefCount write_count
void ALCdevice_UnlockDefault(ALCdevice *device)
void WriteLock(RWLock *lock)
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len)
GLenum GLenum const GLfloat * coeffs
#define AL_LINEAR_DISTANCE
ALuint ChannelsFromDevFmt(enum DevFmtChannels chans)
#define ALCdevice_Lock(a)
void alc_solaris_deinit(void)
void AppendAllDevicesList(const ALCchar *name)
ALvoid * StartThread(ALuint(*func)(ALvoid *), ALvoid *ptr)
static __inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans, enum DevFmtType type)