18 #ifndef AL_SOFT_deferred_updates
19 #define AL_SOFT_deferred_updates 1
20 #define AL_DEFERRED_UPDATES_SOFT 0xC002
21 typedef ALvoid (AL_APIENTRY
*LPALDEFERUPDATESSOFT
)(void);
22 typedef ALvoid (AL_APIENTRY
*LPALPROCESSUPDATESSOFT
)(void);
23 #ifdef AL_ALEXT_PROTOTYPES
24 AL_API ALvoid AL_APIENTRY
alDeferUpdatesSOFT(void);
25 AL_API ALvoid AL_APIENTRY
alProcessUpdatesSOFT(void);
30 #if defined(HAVE_STDINT_H)
32 typedef int64_t ALint64
;
33 typedef uint64_t ALuint64
;
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
;
45 typedef ptrdiff_t ALintptrEXT
;
46 typedef ptrdiff_t ALsizeiptrEXT
;
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)
59 ALubyte b
[sizeof(ALuint
)];
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)
101 typedef pthread_mutex_t CRITICAL_SECTION
;
102 void InitializeCriticalSection(CRITICAL_SECTION
*cs
);
103 void DeleteCriticalSection(CRITICAL_SECTION
*cs
);
104 void EnterCriticalSection(CRITICAL_SECTION
*cs
);
105 void LeaveCriticalSection(CRITICAL_SECTION
*cs
);
107 ALuint
timeGetTime(void);
108 void Sleep(ALuint t
);
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
);
119 typedef void *volatile XchgPtr
;
121 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
122 typedef ALuint RefCount
;
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
)
157 typedef int RefCount
;
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)
217 typedef LONG RefCount
;
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>
254 typedef int32_t RefCount
;
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
)
262 /* Really? No regular old atomic swap? */
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!"
288 typedef ALuint RefCount
;
293 volatile RefCount read_count
;
294 volatile RefCount write_count
;
295 volatile ALenum read_lock
;
296 volatile ALenum read_entry_lock
;
297 volatile ALenum write_lock
;
300 void RWLockInit(RWLock
*lock
);
301 void ReadLock(RWLock
*lock
);
302 void ReadUnlock(RWLock
*lock
);
303 void WriteLock(RWLock
*lock
);
304 void WriteUnlock(RWLock
*lock
);
307 typedef struct UIntMap
{
317 extern UIntMap TlsDestructor
;
319 void InitUIntMap(UIntMap
*map
, ALsizei limit
);
320 void ResetUIntMap(UIntMap
*map
);
321 ALenum
InsertUIntMapEntry(UIntMap
*map
, ALuint key
, ALvoid
*value
);
322 ALvoid
*RemoveUIntMapKey(UIntMap
*map
, ALuint key
);
323 ALvoid
*LookupUIntMapKey(UIntMap
*map
, ALuint key
);
325 static __inline
void LockUIntMapRead(UIntMap
*map
)
326 { ReadLock(&map
->lock
); }
327 static __inline
void UnlockUIntMapRead(UIntMap
*map
)
328 { ReadUnlock(&map
->lock
); }
329 static __inline
void LockUIntMapWrite(UIntMap
*map
)
330 { WriteLock(&map
->lock
); }
331 static __inline
void UnlockUIntMapWrite(UIntMap
*map
)
332 { WriteUnlock(&map
->lock
); }
342 #define DEFAULT_OUTPUT_RATE (44100)
343 #define MIN_OUTPUT_RATE (8000)
346 // Find the next power-of-2 for non-power-of-2 numbers.
347 static __inline ALuint
NextPowerOf2(ALuint value
)
361 /* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
363 static __inline ALint
fastf2i(ALfloat f
)
367 #elif defined(_MSC_VER) && defined(_M_IX86)
376 /* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
378 static __inline ALuint
fastf2u(ALfloat f
)
379 { return fastf2i(f
); }
388 ALCenum (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
389 void (*ClosePlayback
)(ALCdevice
*);
390 ALCboolean (*ResetPlayback
)(ALCdevice
*);
391 ALCboolean (*StartPlayback
)(ALCdevice
*);
392 void (*StopPlayback
)(ALCdevice
*);
394 ALCenum (*OpenCapture
)(ALCdevice
*, const ALCchar
*);
395 void (*CloseCapture
)(ALCdevice
*);
396 void (*StartCapture
)(ALCdevice
*);
397 void (*StopCapture
)(ALCdevice
*);
398 ALCenum (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
399 ALCuint (*AvailableSamples
)(ALCdevice
*);
401 void (*Lock
)(ALCdevice
*);
402 void (*Unlock
)(ALCdevice
*);
404 ALint64 (*GetLatency
)(ALCdevice
*);
409 ALCboolean (*Init
)(BackendFuncs
*);
410 void (*Deinit
)(void);
411 void (*Probe
)(enum DevProbe
);
415 ALCboolean
alc_alsa_init(BackendFuncs
*func_list
);
416 void alc_alsa_deinit(void);
417 void alc_alsa_probe(enum DevProbe type
);
418 ALCboolean
alc_oss_init(BackendFuncs
*func_list
);
419 void alc_oss_deinit(void);
420 void alc_oss_probe(enum DevProbe type
);
421 ALCboolean
alc_solaris_init(BackendFuncs
*func_list
);
422 void alc_solaris_deinit(void);
423 void alc_solaris_probe(enum DevProbe type
);
424 ALCboolean
alc_sndio_init(BackendFuncs
*func_list
);
425 void alc_sndio_deinit(void);
426 void alc_sndio_probe(enum DevProbe type
);
427 ALCboolean
alcMMDevApiInit(BackendFuncs
*func_list
);
428 void alcMMDevApiDeinit(void);
429 void alcMMDevApiProbe(enum DevProbe type
);
430 ALCboolean
alcDSoundInit(BackendFuncs
*func_list
);
431 void alcDSoundDeinit(void);
432 void alcDSoundProbe(enum DevProbe type
);
433 ALCboolean
alcWinMMInit(BackendFuncs
*FuncList
);
434 void alcWinMMDeinit(void);
435 void alcWinMMProbe(enum DevProbe type
);
436 ALCboolean
alc_pa_init(BackendFuncs
*func_list
);
437 void alc_pa_deinit(void);
438 void alc_pa_probe(enum DevProbe type
);
439 ALCboolean
alc_wave_init(BackendFuncs
*func_list
);
440 void alc_wave_deinit(void);
441 void alc_wave_probe(enum DevProbe type
);
442 ALCboolean
alc_pulse_init(BackendFuncs
*func_list
);
443 void alc_pulse_deinit(void);
444 void alc_pulse_probe(enum DevProbe type
);
445 ALCboolean
alc_ca_init(BackendFuncs
*func_list
);
446 void alc_ca_deinit(void);
447 void alc_ca_probe(enum DevProbe type
);
448 ALCboolean
alc_opensl_init(BackendFuncs
*func_list
);
449 void alc_opensl_deinit(void);
450 void alc_opensl_probe(enum DevProbe type
);
451 ALCboolean
alc_null_init(BackendFuncs
*func_list
);
452 void alc_null_deinit(void);
453 void alc_null_probe(enum DevProbe type
);
454 ALCboolean
alc_loopback_init(BackendFuncs
*func_list
);
455 void alc_loopback_deinit(void);
456 void alc_loopback_probe(enum DevProbe type
);
460 InverseDistanceClamped
= AL_INVERSE_DISTANCE_CLAMPED
,
461 LinearDistanceClamped
= AL_LINEAR_DISTANCE_CLAMPED
,
462 ExponentDistanceClamped
= AL_EXPONENT_DISTANCE_CLAMPED
,
463 InverseDistance
= AL_INVERSE_DISTANCE
,
464 LinearDistance
= AL_LINEAR_DISTANCE
,
465 ExponentDistance
= AL_EXPONENT_DISTANCE
,
466 DisableDistance
= AL_NONE
,
468 DefaultDistanceModel
= InverseDistanceClamped
496 DevFmtByte
= ALC_BYTE_SOFT
,
497 DevFmtUByte
= ALC_UNSIGNED_BYTE_SOFT
,
498 DevFmtShort
= ALC_SHORT_SOFT
,
499 DevFmtUShort
= ALC_UNSIGNED_SHORT_SOFT
,
500 DevFmtInt
= ALC_INT_SOFT
,
501 DevFmtUInt
= ALC_UNSIGNED_INT_SOFT
,
502 DevFmtFloat
= ALC_FLOAT_SOFT
,
504 DevFmtTypeDefault
= DevFmtFloat
506 enum DevFmtChannels
{
507 DevFmtMono
= ALC_MONO_SOFT
,
508 DevFmtStereo
= ALC_STEREO_SOFT
,
509 DevFmtQuad
= ALC_QUAD_SOFT
,
510 DevFmtX51
= ALC_5POINT1_SOFT
,
511 DevFmtX61
= ALC_6POINT1_SOFT
,
512 DevFmtX71
= ALC_7POINT1_SOFT
,
514 /* Similar to 5.1, except using the side channels instead of back */
515 DevFmtX51Side
= 0x80000000,
517 DevFmtChannelsDefault
= DevFmtStereo
520 ALuint
BytesFromDevFmt(enum DevFmtType type
);
521 ALuint
ChannelsFromDevFmt(enum DevFmtChannels chans
);
522 static __inline ALuint
FrameSizeFromDevFmt(enum DevFmtChannels chans
,
523 enum DevFmtType type
)
525 return ChannelsFromDevFmt(chans
) * BytesFromDevFmt(type
);
529 extern const struct EffectList
{
544 /* Size for temporary storage of buffer data, in ALfloats. Larger values need
545 * more memory, while smaller values may need more iterations. The value needs
546 * to be a sensible size, however, as it constrains the max stepping value used
547 * for mixing, as well as the maximum number of samples per mixing iteration.
549 * The mixer requires being able to do two samplings per mixing loop. With the
550 * cubic resampler (which requires 3 padding samples), this limits a 2048
551 * buffer size to about 2044. This means that buffer_freq*source_pitch cannot
552 * exceed device_freq*2044 for a 32-bit buffer.
555 #define BUFFERSIZE 2048
559 struct ALCdevice_struct
561 volatile RefCount ref
;
563 ALCboolean Connected
;
564 enum DeviceType Type
;
566 CRITICAL_SECTION Mutex
;
571 enum DevFmtChannels FmtChans
;
572 enum DevFmtType FmtType
;
576 volatile ALCenum LastError
;
578 // Maximum number of sources that can be created
579 ALuint MaxNoOfSources
;
580 // Maximum number of slots that can be created
581 ALuint AuxiliaryEffectSlotMax
;
583 ALCuint NumMonoSources
;
584 ALCuint NumStereoSources
;
587 // Map of Buffers for this device
590 // Map of Effects for this device
593 // Map of Filters for this device
596 /* HRTF filter tables */
597 const struct Hrtf
*Hrtf
;
599 // Stereo-to-binaural filter
606 enum Channel DevChannels
[MaxChannels
];
608 enum Channel Speaker2Chan
[MaxChannels
];
609 ALfloat SpeakerAngle
[MaxChannels
];
612 /* Temp storage used for mixing. +1 for the predictive sample. */
613 ALIGN(16) ALfloat SampleData1
[BUFFERSIZE
+1];
614 ALIGN(16) ALfloat SampleData2
[BUFFERSIZE
+1];
616 // Dry path buffer mix
617 ALIGN(16) ALfloat DryBuffer
[MaxChannels
][BUFFERSIZE
];
619 ALIGN(16) ALfloat ClickRemoval
[MaxChannels
];
620 ALIGN(16) ALfloat PendingClicks
[MaxChannels
];
622 /* Default effect slot */
623 struct ALeffectslot
*DefaultSlot
;
625 // Contexts created on this device
626 ALCcontext
*volatile ContextList
;
629 void *ExtraData
; // For the backend's use
631 ALCdevice
*volatile next
;
634 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
635 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
636 #define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
637 #define ALCdevice_StartPlayback(a) ((a)->Funcs->StartPlayback((a)))
638 #define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
639 #define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
640 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
641 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
642 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
643 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
644 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
645 #define ALCdevice_Lock(a) ((a)->Funcs->Lock((a)))
646 #define ALCdevice_Unlock(a) ((a)->Funcs->Unlock((a)))
647 #define ALCdevice_GetLatency(a) ((a)->Funcs->GetLatency((a)))
649 // Frequency was requested by the app or config file
650 #define DEVICE_FREQUENCY_REQUEST (1<<1)
651 // Channel configuration was requested by the config file
652 #define DEVICE_CHANNELS_REQUEST (1<<2)
653 // Sample type was requested by the config file
654 #define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
656 // Stereo sources cover 120-degree angles around +/-90
657 #define DEVICE_WIDE_STEREO (1<<16)
659 // Specifies if the device is currently running
660 #define DEVICE_RUNNING (1<<31)
662 #define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k)))
663 #define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k)))
664 #define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k)))
665 #define RemoveBuffer(m, k) ((struct ALbuffer*)RemoveUIntMapKey(&(m)->BufferMap, (k)))
666 #define RemoveEffect(m, k) ((struct ALeffect*)RemoveUIntMapKey(&(m)->EffectMap, (k)))
667 #define RemoveFilter(m, k) ((struct ALfilter*)RemoveUIntMapKey(&(m)->FilterMap, (k)))
670 struct ALCcontext_struct
672 volatile RefCount ref
;
674 struct ALlistener
*Listener
;
677 UIntMap EffectSlotMap
;
681 volatile ALenum UpdateSources
;
683 volatile enum DistanceModel DistanceModel
;
684 volatile ALboolean SourceDistanceModel
;
686 volatile ALfloat DopplerFactor
;
687 volatile ALfloat DopplerVelocity
;
688 volatile ALfloat SpeedOfSound
;
689 volatile ALenum DeferUpdates
;
691 struct ALsource
**ActiveSources
;
692 ALsizei ActiveSourceCount
;
693 ALsizei MaxActiveSources
;
695 struct ALeffectslot
**ActiveEffectSlots
;
696 ALsizei ActiveEffectSlotCount
;
697 ALsizei MaxActiveEffectSlots
;
700 const ALCchar
*ExtensionList
;
702 ALCcontext
*volatile next
;
705 #define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k)))
706 #define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k)))
707 #define RemoveSource(m, k) ((struct ALsource*)RemoveUIntMapKey(&(m)->SourceMap, (k)))
708 #define RemoveEffectSlot(m, k) ((struct ALeffectslot*)RemoveUIntMapKey(&(m)->EffectSlotMap, (k)))
711 ALCcontext
*GetContextRef(void);
713 void ALCcontext_IncRef(ALCcontext
*context
);
714 void ALCcontext_DecRef(ALCcontext
*context
);
716 void AppendAllDevicesList(const ALCchar
*name
);
717 void AppendCaptureDeviceList(const ALCchar
*name
);
719 void ALCdevice_LockDefault(ALCdevice
*device
);
720 void ALCdevice_UnlockDefault(ALCdevice
*device
);
721 ALint64
ALCdevice_GetLatencyDefault(ALCdevice
*device
);
723 static __inline
void LockContext(ALCcontext
*context
)
724 { ALCdevice_Lock(context
->Device
); }
725 static __inline
void UnlockContext(ALCcontext
*context
)
726 { ALCdevice_Unlock(context
->Device
); }
729 void *al_malloc(size_t alignment
, size_t size
);
730 void *al_calloc(size_t alignment
, size_t size
);
731 void al_free(void *ptr
);
739 void SetMixerFPUMode(FPUCtl
*ctl
);
740 void RestoreFPUMode(const FPUCtl
*ctl
);
742 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
743 ALuint
StopThread(ALvoid
*thread
);
745 typedef struct RingBuffer RingBuffer
;
746 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
747 void DestroyRingBuffer(RingBuffer
*ring
);
748 ALsizei
RingBufferSize(RingBuffer
*ring
);
749 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
750 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
752 void ReadALConfig(void);
753 void FreeALConfig(void);
754 int ConfigValueExists(const char *blockName
, const char *keyName
);
755 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
756 int GetConfigValueBool(const char *blockName
, const char *keyName
, int def
);
757 int ConfigValueStr(const char *blockName
, const char *keyName
, const char **ret
);
758 int ConfigValueInt(const char *blockName
, const char *keyName
, int *ret
);
759 int ConfigValueUInt(const char *blockName
, const char *keyName
, unsigned int *ret
);
760 int ConfigValueFloat(const char *blockName
, const char *keyName
, float *ret
);
762 void SetRTPriority(void);
764 void SetDefaultChannelOrder(ALCdevice
*device
);
765 void SetDefaultWFXChannelOrder(ALCdevice
*device
);
767 const ALCchar
*DevFmtTypeString(enum DevFmtType type
);
768 const ALCchar
*DevFmtChannelsString(enum DevFmtChannels chans
);
770 #define HRIR_BITS (7)
771 #define HRIR_LENGTH (1<<HRIR_BITS)
772 #define HRIR_MASK (HRIR_LENGTH-1)
773 #define HRTFDELAY_BITS (20)
774 #define HRTFDELAY_FRACONE (1<<HRTFDELAY_BITS)
775 #define HRTFDELAY_MASK (HRTFDELAY_FRACONE-1)
776 const struct Hrtf
*GetHrtf(ALCdevice
*device
);
777 void FreeHrtfs(void);
778 ALuint
GetHrtfIrSize (const struct Hrtf
*Hrtf
);
779 ALfloat
CalcHrtfDelta(ALfloat oldGain
, ALfloat newGain
, const ALfloat olddir
[3], const ALfloat newdir
[3]);
780 void GetLerpedHrtfCoeffs(const struct Hrtf
*Hrtf
, ALfloat elevation
, ALfloat azimuth
, ALfloat gain
, ALfloat (*coeffs
)[2], ALuint
*delays
);
781 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
);
783 void al_print(const char *type
, const char *func
, const char *fmt
, ...) PRINTF_STYLE(3,4);
784 #define AL_PRINT(T, ...) al_print((T), __FUNCTION__, __VA_ARGS__)
786 extern FILE *LogFile
;
794 extern enum LogLevel LogLevel
;
796 #define TRACEREF(...) do { \
797 if(LogLevel >= LogRef) \
798 AL_PRINT("(--)", __VA_ARGS__); \
801 #define TRACE(...) do { \
802 if(LogLevel >= LogTrace) \
803 AL_PRINT("(II)", __VA_ARGS__); \
806 #define WARN(...) do { \
807 if(LogLevel >= LogWarning) \
808 AL_PRINT("(WW)", __VA_ARGS__); \
811 #define ERR(...) do { \
812 if(LogLevel >= LogError) \
813 AL_PRINT("(EE)", __VA_ARGS__); \
817 extern ALint RTPrioLevel
;
820 extern ALuint CPUCapFlags
;
826 void FillCPUCaps(ALuint capfilter
);
830 * Starts a try block. Must not be nested within another try block within the
833 #define al_try do { \
838 * After a try or another catch block, runs the next block if the given value
841 #define al_catch(val) else if(_al_err == (val))
843 * After a try or catch block, runs the next block for any value thrown and not
846 #define al_catchany() else
847 /** Marks the end of the final catch (or the try) block. */
848 #define al_endtry } while(0)
851 * The given integer value is "thrown" so as to be caught by a catch block.
852 * Must be called in a try block within the same function. The value must not
855 #define al_throw(e) do { \
857 assert(_al_err != 0); \
858 goto _al_try_label; \
860 /** Sets an AL error on the given context, before throwing the error code. */
861 #define al_throwerr(ctx, err) do { \
862 alSetError((ctx), (err)); \
867 * Throws an AL_INVALID_VALUE error with the given ctx if the given condition
870 #define CHECK_VALUE(ctx, cond) do { \
872 al_throwerr((ctx), AL_INVALID_VALUE); \