18 /* Define int64_t and uint64_t types */
19 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
21 #elif defined(_WIN32) && defined(__GNUC__)
24 typedef __int64
int64_t;
25 typedef unsigned __int64
uint64_t;
27 /* Fallback if nothing above works */
31 #ifndef AL_SOFT_deferred_updates
32 #define AL_SOFT_deferred_updates 1
33 #define AL_DEFERRED_UPDATES_SOFT 0xC002
34 typedef ALvoid (AL_APIENTRY
*LPALDEFERUPDATESSOFT
)(void);
35 typedef ALvoid (AL_APIENTRY
*LPALPROCESSUPDATESSOFT
)(void);
36 #ifdef AL_ALEXT_PROTOTYPES
37 AL_API ALvoid AL_APIENTRY
alDeferUpdatesSOFT(void);
38 AL_API ALvoid AL_APIENTRY
alProcessUpdatesSOFT(void);
42 #ifndef AL_SOFT_source_latency
43 #define AL_SOFT_source_latency 1
44 #define AL_SAMPLE_OFFSET_LATENCY_SOFT 0x1200
45 #define AL_SEC_OFFSET_LATENCY_SOFT 0x1201
46 typedef int64_t ALint64SOFT
;
47 typedef uint64_t ALuint64SOFT
;
48 typedef void (AL_APIENTRY
*LPALGETSOURCEDSOFT
)(ALuint
,ALenum
,ALdouble
*);
49 typedef void (AL_APIENTRY
*LPALGETSOURCE3DSOFT
)(ALuint
,ALenum
,ALdouble
*,ALdouble
*,ALdouble
*);
50 typedef void (AL_APIENTRY
*LPALGETSOURCEDVSOFT
)(ALuint
,ALenum
,ALdouble
*);
51 typedef void (AL_APIENTRY
*LPALGETSOURCEI64SOFT
)(ALuint
,ALenum
,ALint64SOFT
*);
52 typedef void (AL_APIENTRY
*LPALGETSOURCE3I64SOFT
)(ALuint
,ALenum
,ALint64SOFT
*,ALint64SOFT
*,ALint64SOFT
*);
53 typedef void (AL_APIENTRY
*LPALGETSOURCEI64VSOFT
)(ALuint
,ALenum
,ALint64SOFT
*);
54 #ifdef AL_ALEXT_PROTOTYPES
55 AL_API
void AL_APIENTRY
alGetSourcedSOFT(ALuint source
, ALenum param
, ALdouble
*value
);
56 AL_API
void AL_APIENTRY
alGetSource3dSOFT(ALuint source
, ALenum param
, ALdouble
*value1
, ALdouble
*value2
, ALdouble
*value3
);
57 AL_API
void AL_APIENTRY
alGetSourcedvSOFT(ALuint source
, ALenum param
, ALdouble
*values
);
58 AL_API
void AL_APIENTRY
alGetSourcei64SOFT(ALuint source
, ALenum param
, ALint64SOFT
*value
);
59 AL_API
void AL_APIENTRY
alGetSource3i64SOFT(ALuint source
, ALenum param
, ALint64SOFT
*value1
, ALint64SOFT
*value2
, ALint64SOFT
*value3
);
60 AL_API
void AL_APIENTRY
alGetSourcei64vSOFT(ALuint source
, ALenum param
, ALint64SOFT
*values
);
65 #if defined(HAVE_STDINT_H)
67 typedef int64_t ALint64
;
68 typedef uint64_t ALuint64
;
69 #elif defined(HAVE___INT64)
70 typedef __int64 ALint64
;
71 typedef unsigned __int64 ALuint64
;
72 #elif (SIZEOF_LONG == 8)
74 typedef unsigned long ALuint64
;
75 #elif (SIZEOF_LONG_LONG == 8)
76 typedef long long ALint64
;
77 typedef unsigned long long ALuint64
;
80 typedef ptrdiff_t ALintptrEXT
;
81 typedef ptrdiff_t ALsizeiptrEXT
;
83 #define MAKEU64(x,y) (((ALuint64)(x)<<32)|(ALuint64)(y))
85 #ifdef HAVE_GCC_FORMAT
86 #define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
88 #define PRINTF_STYLE(x, y)
91 #if defined(HAVE_RESTRICT)
92 #define RESTRICT restrict
93 #elif defined(HAVE___RESTRICT)
94 #define RESTRICT __restrict
102 ALubyte b
[sizeof(ALuint
)];
103 } EndianTest
= { 1 };
104 #define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
106 #define COUNTOF(x) (sizeof((x))/sizeof((x)[0]))
112 typedef DWORD pthread_key_t
;
113 int pthread_key_create(pthread_key_t
*key
, void (*callback
)(void*));
114 int pthread_key_delete(pthread_key_t key
);
115 void *pthread_getspecific(pthread_key_t key
);
116 int pthread_setspecific(pthread_key_t key
, void *val
);
118 #define HAVE_DYNLOAD 1
119 void *LoadLib(const char *name
);
120 void CloseLib(void *handle
);
121 void *GetSymbol(void *handle
, const char *name
);
123 WCHAR
*strdupW(const WCHAR
*str
);
125 typedef LONG pthread_once_t
;
126 #define PTHREAD_ONCE_INIT 0
127 void pthread_once(pthread_once_t
*once
, void (*callback
)(void));
129 static __inline
int sched_yield(void)
130 { SwitchToThread(); return 0; }
137 #include <sys/time.h>
141 #define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0)
143 typedef pthread_mutex_t CRITICAL_SECTION
;
144 void InitializeCriticalSection(CRITICAL_SECTION
*cs
);
145 void DeleteCriticalSection(CRITICAL_SECTION
*cs
);
146 void EnterCriticalSection(CRITICAL_SECTION
*cs
);
147 void LeaveCriticalSection(CRITICAL_SECTION
*cs
);
149 ALuint
timeGetTime(void);
150 void Sleep(ALuint t
);
152 #if defined(HAVE_DLFCN_H)
153 #define HAVE_DYNLOAD 1
154 void *LoadLib(const char *name
);
155 void CloseLib(void *handle
);
156 void *GetSymbol(void *handle
, const char *name
);
161 typedef void *volatile XchgPtr
;
163 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
164 typedef ALuint RefCount
;
165 static __inline RefCount
IncrementRef(volatile RefCount
*ptr
)
166 { return __sync_add_and_fetch(ptr
, 1); }
167 static __inline RefCount
DecrementRef(volatile RefCount
*ptr
)
168 { return __sync_sub_and_fetch(ptr
, 1); }
170 static __inline
int ExchangeInt(volatile int *ptr
, int newval
)
172 return __sync_lock_test_and_set(ptr
, newval
);
174 static __inline
void *ExchangePtr(XchgPtr
*ptr
, void *newval
)
176 return __sync_lock_test_and_set(ptr
, newval
);
178 static __inline ALboolean
CompExchangeInt(volatile int *ptr
, int oldval
, int newval
)
180 return __sync_bool_compare_and_swap(ptr
, oldval
, newval
);
182 static __inline ALboolean
CompExchangePtr(XchgPtr
*ptr
, void *oldval
, void *newval
)
184 return __sync_bool_compare_and_swap(ptr
, oldval
, newval
);
187 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
189 static __inline
int xaddl(volatile int *dest
, int incr
)
192 __asm__
__volatile__("lock; xaddl %0,(%1)"
194 : "r" (dest
), "0" (incr
)
199 typedef int RefCount
;
200 static __inline RefCount
IncrementRef(volatile RefCount
*ptr
)
201 { return xaddl(ptr
, 1)+1; }
202 static __inline RefCount
DecrementRef(volatile RefCount
*ptr
)
203 { return xaddl(ptr
, -1)-1; }
205 static __inline
int ExchangeInt(volatile int *dest
, int newval
)
208 __asm__
__volatile__("lock; xchgl %0,(%1)"
210 : "r" (dest
), "0" (newval
)
215 static __inline ALboolean
CompExchangeInt(volatile int *dest
, int oldval
, int newval
)
218 __asm__
__volatile__("lock; cmpxchgl %2,(%1)"
220 : "r" (dest
), "r" (newval
), "0" (oldval
)
222 return ret
== oldval
;
225 static __inline
void *ExchangePtr(XchgPtr
*dest
, void *newval
)
228 __asm__
__volatile__(
230 "lock; xchgl %0,(%1)"
232 "lock; xchgq %0,(%1)"
235 : "r" (dest
), "0" (newval
)
241 static __inline ALboolean
CompExchangePtr(XchgPtr
*dest
, void *oldval
, void *newval
)
244 __asm__
__volatile__(
246 "lock; cmpxchgl %2,(%1)"
248 "lock; cmpxchgq %2,(%1)"
251 : "r" (dest
), "r" (newval
), "0" (oldval
)
254 return ret
== oldval
;
257 #elif defined(_WIN32)
259 typedef LONG RefCount
;
260 static __inline RefCount
IncrementRef(volatile RefCount
*ptr
)
261 { return InterlockedIncrement(ptr
); }
262 static __inline RefCount
DecrementRef(volatile RefCount
*ptr
)
263 { return InterlockedDecrement(ptr
); }
265 extern ALbyte LONG_size_does_not_match_int
[(sizeof(LONG
)==sizeof(int))?1:-1];
267 static __inline
int ExchangeInt(volatile int *ptr
, int newval
)
273 return InterlockedExchange(u
.l
, newval
);
275 static __inline
void *ExchangePtr(XchgPtr
*ptr
, void *newval
)
277 return InterlockedExchangePointer(ptr
, newval
);
279 static __inline ALboolean
CompExchangeInt(volatile int *ptr
, int oldval
, int newval
)
285 return InterlockedCompareExchange(u
.l
, newval
, oldval
) == oldval
;
287 static __inline ALboolean
CompExchangePtr(XchgPtr
*ptr
, void *oldval
, void *newval
)
289 return InterlockedCompareExchangePointer(ptr
, newval
, oldval
) == oldval
;
292 #elif defined(__APPLE__)
294 #include <libkern/OSAtomic.h>
296 typedef int32_t RefCount
;
297 static __inline RefCount
IncrementRef(volatile RefCount
*ptr
)
298 { return OSAtomicIncrement32Barrier(ptr
); }
299 static __inline RefCount
DecrementRef(volatile RefCount
*ptr
)
300 { return OSAtomicDecrement32Barrier(ptr
); }
302 static __inline
int ExchangeInt(volatile int *ptr
, int newval
)
304 /* Really? No regular old atomic swap? */
308 } while(!OSAtomicCompareAndSwap32Barrier(oldval
, newval
, ptr
));
311 static __inline
void *ExchangePtr(XchgPtr
*ptr
, void *newval
)
316 } while(!OSAtomicCompareAndSwapPtrBarrier(oldval
, newval
, ptr
));
319 static __inline ALboolean
CompExchangeInt(volatile int *ptr
, int oldval
, int newval
)
321 return OSAtomicCompareAndSwap32Barrier(oldval
, newval
, ptr
);
323 static __inline ALboolean
CompExchangePtr(XchgPtr
*ptr
, void *oldval
, void *newval
)
325 return OSAtomicCompareAndSwapPtrBarrier(oldval
, newval
, ptr
);
329 #error "No atomic functions available on this platform!"
330 typedef ALuint RefCount
;
335 volatile RefCount read_count
;
336 volatile RefCount write_count
;
337 volatile ALenum read_lock
;
338 volatile ALenum read_entry_lock
;
339 volatile ALenum write_lock
;
342 void RWLockInit(RWLock
*lock
);
343 void ReadLock(RWLock
*lock
);
344 void ReadUnlock(RWLock
*lock
);
345 void WriteLock(RWLock
*lock
);
346 void WriteUnlock(RWLock
*lock
);
349 typedef struct UIntMap
{
359 extern UIntMap TlsDestructor
;
361 void InitUIntMap(UIntMap
*map
, ALsizei limit
);
362 void ResetUIntMap(UIntMap
*map
);
363 ALenum
InsertUIntMapEntry(UIntMap
*map
, ALuint key
, ALvoid
*value
);
364 ALvoid
*RemoveUIntMapKey(UIntMap
*map
, ALuint key
);
365 ALvoid
*LookupUIntMapKey(UIntMap
*map
, ALuint key
);
367 static __inline
void LockUIntMapRead(UIntMap
*map
)
368 { ReadLock(&map
->lock
); }
369 static __inline
void UnlockUIntMapRead(UIntMap
*map
)
370 { ReadUnlock(&map
->lock
); }
371 static __inline
void LockUIntMapWrite(UIntMap
*map
)
372 { WriteLock(&map
->lock
); }
373 static __inline
void UnlockUIntMapWrite(UIntMap
*map
)
374 { WriteUnlock(&map
->lock
); }
376 #include "alListener.h"
385 #define DEFAULT_OUTPUT_RATE (44100)
386 #define MIN_OUTPUT_RATE (8000)
389 // Find the next power-of-2 for non-power-of-2 numbers.
390 static __inline ALuint
NextPowerOf2(ALuint value
)
406 /* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
408 static __inline ALint
fastf2i(ALfloat f
)
412 #elif defined(_MSC_VER) && defined(_M_IX86)
421 /* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
423 static __inline ALuint
fastf2u(ALfloat f
)
424 { return fastf2i(f
); }
433 ALCenum (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
434 void (*ClosePlayback
)(ALCdevice
*);
435 ALCboolean (*ResetPlayback
)(ALCdevice
*);
436 ALCboolean (*StartPlayback
)(ALCdevice
*);
437 void (*StopPlayback
)(ALCdevice
*);
439 ALCenum (*OpenCapture
)(ALCdevice
*, const ALCchar
*);
440 void (*CloseCapture
)(ALCdevice
*);
441 void (*StartCapture
)(ALCdevice
*);
442 void (*StopCapture
)(ALCdevice
*);
443 ALCenum (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
444 ALCuint (*AvailableSamples
)(ALCdevice
*);
446 void (*Lock
)(ALCdevice
*);
447 void (*Unlock
)(ALCdevice
*);
449 ALint64 (*GetLatency
)(ALCdevice
*);
454 ALCboolean (*Init
)(BackendFuncs
*);
455 void (*Deinit
)(void);
456 void (*Probe
)(enum DevProbe
);
460 ALCboolean
alc_alsa_init(BackendFuncs
*func_list
);
461 void alc_alsa_deinit(void);
462 void alc_alsa_probe(enum DevProbe type
);
463 ALCboolean
alc_oss_init(BackendFuncs
*func_list
);
464 void alc_oss_deinit(void);
465 void alc_oss_probe(enum DevProbe type
);
466 ALCboolean
alc_solaris_init(BackendFuncs
*func_list
);
467 void alc_solaris_deinit(void);
468 void alc_solaris_probe(enum DevProbe type
);
469 ALCboolean
alc_sndio_init(BackendFuncs
*func_list
);
470 void alc_sndio_deinit(void);
471 void alc_sndio_probe(enum DevProbe type
);
472 ALCboolean
alcMMDevApiInit(BackendFuncs
*func_list
);
473 void alcMMDevApiDeinit(void);
474 void alcMMDevApiProbe(enum DevProbe type
);
475 ALCboolean
alcDSoundInit(BackendFuncs
*func_list
);
476 void alcDSoundDeinit(void);
477 void alcDSoundProbe(enum DevProbe type
);
478 ALCboolean
alcWinMMInit(BackendFuncs
*FuncList
);
479 void alcWinMMDeinit(void);
480 void alcWinMMProbe(enum DevProbe type
);
481 ALCboolean
alc_pa_init(BackendFuncs
*func_list
);
482 void alc_pa_deinit(void);
483 void alc_pa_probe(enum DevProbe type
);
484 ALCboolean
alc_wave_init(BackendFuncs
*func_list
);
485 void alc_wave_deinit(void);
486 void alc_wave_probe(enum DevProbe type
);
487 ALCboolean
alc_pulse_init(BackendFuncs
*func_list
);
488 void alc_pulse_deinit(void);
489 void alc_pulse_probe(enum DevProbe type
);
490 ALCboolean
alc_ca_init(BackendFuncs
*func_list
);
491 void alc_ca_deinit(void);
492 void alc_ca_probe(enum DevProbe type
);
493 ALCboolean
alc_opensl_init(BackendFuncs
*func_list
);
494 void alc_opensl_deinit(void);
495 void alc_opensl_probe(enum DevProbe type
);
496 ALCboolean
alc_null_init(BackendFuncs
*func_list
);
497 void alc_null_deinit(void);
498 void alc_null_probe(enum DevProbe type
);
499 ALCboolean
alc_loopback_init(BackendFuncs
*func_list
);
500 void alc_loopback_deinit(void);
501 void alc_loopback_probe(enum DevProbe type
);
505 InverseDistanceClamped
= AL_INVERSE_DISTANCE_CLAMPED
,
506 LinearDistanceClamped
= AL_LINEAR_DISTANCE_CLAMPED
,
507 ExponentDistanceClamped
= AL_EXPONENT_DISTANCE_CLAMPED
,
508 InverseDistance
= AL_INVERSE_DISTANCE
,
509 LinearDistance
= AL_LINEAR_DISTANCE
,
510 ExponentDistance
= AL_EXPONENT_DISTANCE
,
511 DisableDistance
= AL_NONE
,
513 DefaultDistanceModel
= InverseDistanceClamped
541 DevFmtByte
= ALC_BYTE_SOFT
,
542 DevFmtUByte
= ALC_UNSIGNED_BYTE_SOFT
,
543 DevFmtShort
= ALC_SHORT_SOFT
,
544 DevFmtUShort
= ALC_UNSIGNED_SHORT_SOFT
,
545 DevFmtInt
= ALC_INT_SOFT
,
546 DevFmtUInt
= ALC_UNSIGNED_INT_SOFT
,
547 DevFmtFloat
= ALC_FLOAT_SOFT
,
549 DevFmtTypeDefault
= DevFmtFloat
551 enum DevFmtChannels
{
552 DevFmtMono
= ALC_MONO_SOFT
,
553 DevFmtStereo
= ALC_STEREO_SOFT
,
554 DevFmtQuad
= ALC_QUAD_SOFT
,
555 DevFmtX51
= ALC_5POINT1_SOFT
,
556 DevFmtX61
= ALC_6POINT1_SOFT
,
557 DevFmtX71
= ALC_7POINT1_SOFT
,
559 /* Similar to 5.1, except using the side channels instead of back */
560 DevFmtX51Side
= 0x80000000,
562 DevFmtChannelsDefault
= DevFmtStereo
565 ALuint
BytesFromDevFmt(enum DevFmtType type
);
566 ALuint
ChannelsFromDevFmt(enum DevFmtChannels chans
);
567 static __inline ALuint
FrameSizeFromDevFmt(enum DevFmtChannels chans
,
568 enum DevFmtType type
)
570 return ChannelsFromDevFmt(chans
) * BytesFromDevFmt(type
);
574 extern const struct EffectList
{
589 /* Size for temporary storage of buffer data, in ALfloats. Larger values need
590 * more stack, while smaller values may need more iterations. The value needs
591 * to be a sensible size, however, as it constrains the max stepping value used
592 * for mixing, as well as the maximum number of samples per mixing iteration.
594 * The mixer requires being able to do two samplings per mixing loop. With the
595 * cubic resampler (which requires 3 padding samples), this limits a 2048
596 * buffer size to about 2044. This means that buffer_freq*source_pitch cannot
597 * exceed device_freq*2044 for a 32-bit buffer.
600 #define BUFFERSIZE 2048
604 struct ALCdevice_struct
606 volatile RefCount ref
;
608 ALCboolean Connected
;
609 enum DeviceType Type
;
611 CRITICAL_SECTION Mutex
;
616 enum DevFmtChannels FmtChans
;
617 enum DevFmtType FmtType
;
621 volatile ALCenum LastError
;
623 // Maximum number of sources that can be created
624 ALuint MaxNoOfSources
;
625 // Maximum number of slots that can be created
626 ALuint AuxiliaryEffectSlotMax
;
628 ALCuint NumMonoSources
;
629 ALCuint NumStereoSources
;
632 // Map of Buffers for this device
635 // Map of Effects for this device
638 // Map of Filters for this device
641 /* HRTF filter tables */
642 const struct Hrtf
*Hrtf
;
644 // Stereo-to-binaural filter
651 enum Channel DevChannels
[MaxChannels
];
653 enum Channel Speaker2Chan
[MaxChannels
];
654 ALfloat SpeakerAngle
[MaxChannels
];
657 // Dry path buffer mix
658 ALIGN(16) ALfloat DryBuffer
[MaxChannels
][BUFFERSIZE
];
660 ALIGN(16) ALfloat ClickRemoval
[MaxChannels
];
661 ALIGN(16) ALfloat PendingClicks
[MaxChannels
];
663 /* Default effect slot */
664 struct ALeffectslot
*DefaultSlot
;
666 // Contexts created on this device
667 ALCcontext
*volatile ContextList
;
670 void *ExtraData
; // For the backend's use
672 ALCdevice
*volatile next
;
675 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
676 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
677 #define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
678 #define ALCdevice_StartPlayback(a) ((a)->Funcs->StartPlayback((a)))
679 #define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
680 #define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
681 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
682 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
683 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
684 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
685 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
686 #define ALCdevice_Lock(a) ((a)->Funcs->Lock((a)))
687 #define ALCdevice_Unlock(a) ((a)->Funcs->Unlock((a)))
688 #define ALCdevice_GetLatency(a) ((a)->Funcs->GetLatency((a)))
690 // Frequency was requested by the app or config file
691 #define DEVICE_FREQUENCY_REQUEST (1<<1)
692 // Channel configuration was requested by the config file
693 #define DEVICE_CHANNELS_REQUEST (1<<2)
694 // Sample type was requested by the config file
695 #define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
697 // Stereo sources cover 120-degree angles around +/-90
698 #define DEVICE_WIDE_STEREO (1<<16)
700 // Specifies if the device is currently running
701 #define DEVICE_RUNNING (1<<31)
703 #define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k)))
704 #define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k)))
705 #define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k)))
706 #define RemoveBuffer(m, k) ((struct ALbuffer*)RemoveUIntMapKey(&(m)->BufferMap, (k)))
707 #define RemoveEffect(m, k) ((struct ALeffect*)RemoveUIntMapKey(&(m)->EffectMap, (k)))
708 #define RemoveFilter(m, k) ((struct ALfilter*)RemoveUIntMapKey(&(m)->FilterMap, (k)))
711 struct ALCcontext_struct
713 volatile RefCount ref
;
718 UIntMap EffectSlotMap
;
722 volatile ALenum UpdateSources
;
724 volatile enum DistanceModel DistanceModel
;
725 volatile ALboolean SourceDistanceModel
;
727 volatile ALfloat DopplerFactor
;
728 volatile ALfloat DopplerVelocity
;
729 volatile ALfloat SpeedOfSound
;
730 volatile ALenum DeferUpdates
;
732 struct ALsource
**ActiveSources
;
733 ALsizei ActiveSourceCount
;
734 ALsizei MaxActiveSources
;
736 struct ALeffectslot
**ActiveEffectSlots
;
737 ALsizei ActiveEffectSlotCount
;
738 ALsizei MaxActiveEffectSlots
;
741 const ALCchar
*ExtensionList
;
743 ALCcontext
*volatile next
;
746 #define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k)))
747 #define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k)))
748 #define RemoveSource(m, k) ((struct ALsource*)RemoveUIntMapKey(&(m)->SourceMap, (k)))
749 #define RemoveEffectSlot(m, k) ((struct ALeffectslot*)RemoveUIntMapKey(&(m)->EffectSlotMap, (k)))
752 ALCcontext
*GetContextRef(void);
754 void ALCcontext_IncRef(ALCcontext
*context
);
755 void ALCcontext_DecRef(ALCcontext
*context
);
757 void AppendAllDevicesList(const ALCchar
*name
);
758 void AppendCaptureDeviceList(const ALCchar
*name
);
760 void ALCdevice_LockDefault(ALCdevice
*device
);
761 void ALCdevice_UnlockDefault(ALCdevice
*device
);
762 ALint64
ALCdevice_GetLatencyDefault(ALCdevice
*device
);
764 static __inline
void LockContext(ALCcontext
*context
)
765 { ALCdevice_Lock(context
->Device
); }
766 static __inline
void UnlockContext(ALCcontext
*context
)
767 { ALCdevice_Unlock(context
->Device
); }
770 void *al_malloc(size_t alignment
, size_t size
);
771 void *al_calloc(size_t alignment
, size_t size
);
772 void al_free(void *ptr
);
780 void SetMixerFPUMode(FPUCtl
*ctl
);
781 void RestoreFPUMode(const FPUCtl
*ctl
);
783 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
784 ALuint
StopThread(ALvoid
*thread
);
786 typedef struct RingBuffer RingBuffer
;
787 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
788 void DestroyRingBuffer(RingBuffer
*ring
);
789 ALsizei
RingBufferSize(RingBuffer
*ring
);
790 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
791 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
793 void ReadALConfig(void);
794 void FreeALConfig(void);
795 int ConfigValueExists(const char *blockName
, const char *keyName
);
796 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
797 int GetConfigValueBool(const char *blockName
, const char *keyName
, int def
);
798 int ConfigValueStr(const char *blockName
, const char *keyName
, const char **ret
);
799 int ConfigValueInt(const char *blockName
, const char *keyName
, int *ret
);
800 int ConfigValueUInt(const char *blockName
, const char *keyName
, unsigned int *ret
);
801 int ConfigValueFloat(const char *blockName
, const char *keyName
, float *ret
);
803 void SetRTPriority(void);
805 void SetDefaultChannelOrder(ALCdevice
*device
);
806 void SetDefaultWFXChannelOrder(ALCdevice
*device
);
808 const ALCchar
*DevFmtTypeString(enum DevFmtType type
);
809 const ALCchar
*DevFmtChannelsString(enum DevFmtChannels chans
);
811 #define HRIR_BITS (7)
812 #define HRIR_LENGTH (1<<HRIR_BITS)
813 #define HRIR_MASK (HRIR_LENGTH-1)
814 #define HRTFDELAY_BITS (20)
815 #define HRTFDELAY_FRACONE (1<<HRTFDELAY_BITS)
816 #define HRTFDELAY_MASK (HRTFDELAY_FRACONE-1)
817 const struct Hrtf
*GetHrtf(ALCdevice
*device
);
818 void FreeHrtfs(void);
819 ALuint
GetHrtfIrSize (const struct Hrtf
*Hrtf
);
820 ALfloat
CalcHrtfDelta(ALfloat oldGain
, ALfloat newGain
, const ALfloat olddir
[3], const ALfloat newdir
[3]);
821 void GetLerpedHrtfCoeffs(const struct Hrtf
*Hrtf
, ALfloat elevation
, ALfloat azimuth
, ALfloat gain
, ALfloat (*coeffs
)[2], ALuint
*delays
);
822 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
);
824 void al_print(const char *func
, const char *fmt
, ...) PRINTF_STYLE(2,3);
825 #define AL_PRINT(...) al_print(__FUNCTION__, __VA_ARGS__)
827 extern FILE *LogFile
;
835 extern enum LogLevel LogLevel
;
837 #define TRACEREF(...) do { \
838 if(LogLevel >= LogRef) \
839 AL_PRINT(__VA_ARGS__); \
842 #define TRACE(...) do { \
843 if(LogLevel >= LogTrace) \
844 AL_PRINT(__VA_ARGS__); \
847 #define WARN(...) do { \
848 if(LogLevel >= LogWarning) \
849 AL_PRINT(__VA_ARGS__); \
852 #define ERR(...) do { \
853 if(LogLevel >= LogError) \
854 AL_PRINT(__VA_ARGS__); \
858 extern ALint RTPrioLevel
;
861 extern ALuint CPUCapFlags
;
867 void FillCPUCaps(ALuint capfilter
);
871 * Starts a try block. Must not be nested within another try block within the
874 #define al_try do { \
879 * After a try or another catch block, runs the next block if the given value
882 #define al_catch(val) else if(_al_err == (val))
884 * After a try or catch block, runs the next block for any value thrown and not
887 #define al_catchany() else
888 /** Marks the end of the final catch (or the try) block. */
889 #define al_endtry } while(0)
892 * The given integer value is "thrown" so as to be caught by a catch block.
893 * Must be called in a try block within the same function. The value must not
896 #define al_throw(e) do { \
898 assert(_al_err != 0); \
899 goto _al_try_label; \
901 /** Sets an AL error on the given context, before throwing the error code. */
902 #define al_throwerr(ctx, err) do { \
903 alSetError((ctx), (err)); \
908 * Throws an AL_INVALID_VALUE error with the given ctx if the given condition
911 #define CHECK_VALUE(ctx, cond) do { \
913 al_throwerr((ctx), AL_INVALID_VALUE); \