Finalize ALC_SOFT_loopback
[openal-soft.git] / OpenAL32 / Include / alMain.h
blob157479133de2b2ba9c40d24640952dc8ae9fd2d2
1 #ifndef AL_MAIN_H
2 #define AL_MAIN_H
4 #include <string.h>
5 #include <stdio.h>
6 #include <stdarg.h>
8 #ifdef HAVE_FENV_H
9 #include <fenv.h>
10 #endif
12 #ifdef HAVE_FPU_CONTROL_H
13 #include <fpu_control.h>
14 #endif
16 #include "AL/al.h"
17 #include "AL/alc.h"
18 #include "AL/alext.h"
20 #ifndef AL_SOFT_deferred_updates
21 #define AL_SOFT_deferred_updates 1
22 #define AL_DEFERRED_UPDATES_SOFT 0xC002
23 typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void);
24 typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void);
25 #ifdef AL_ALEXT_PROTOTYPES
26 AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void);
27 AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void);
28 #endif
29 #endif
32 #if defined(HAVE_STDINT_H)
33 #include <stdint.h>
34 typedef int64_t ALint64;
35 typedef uint64_t ALuint64;
36 #elif defined(HAVE___INT64)
37 typedef __int64 ALint64;
38 typedef unsigned __int64 ALuint64;
39 #elif (SIZEOF_LONG == 8)
40 typedef long ALint64;
41 typedef unsigned long ALuint64;
42 #elif (SIZEOF_LONG_LONG == 8)
43 typedef long long ALint64;
44 typedef unsigned long long ALuint64;
45 #endif
47 typedef ptrdiff_t ALintptrEXT;
48 typedef ptrdiff_t ALsizeiptrEXT;
50 #ifdef HAVE_GCC_FORMAT
51 #define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
52 #else
53 #define PRINTF_STYLE(x, y)
54 #endif
56 #if defined(HAVE_RESTRICT)
57 #define RESTRICT restrict
58 #elif defined(HAVE___RESTRICT)
59 #define RESTRICT __restrict
60 #else
61 #define RESTRICT
62 #endif
65 static const union {
66 ALuint u;
67 ALubyte b[sizeof(ALuint)];
68 } EndianTest = { 1 };
69 #define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
71 #define COUNTOF(x) (sizeof((x))/sizeof((x)[0]))
73 #ifdef _WIN32
75 #include <windows.h>
77 typedef DWORD pthread_key_t;
78 int pthread_key_create(pthread_key_t *key, void (*callback)(void*));
79 int pthread_key_delete(pthread_key_t key);
80 void *pthread_getspecific(pthread_key_t key);
81 int pthread_setspecific(pthread_key_t key, void *val);
83 #define HAVE_DYNLOAD 1
84 void *LoadLib(const char *name);
85 void CloseLib(void *handle);
86 void *GetSymbol(void *handle, const char *name);
88 WCHAR *strdupW(const WCHAR *str);
90 typedef LONG pthread_once_t;
91 #define PTHREAD_ONCE_INIT 0
92 void pthread_once(pthread_once_t *once, void (*callback)(void));
94 static __inline int sched_yield(void)
95 { SwitchToThread(); return 0; }
97 #else
99 #include <unistd.h>
100 #include <assert.h>
101 #include <pthread.h>
102 #ifdef HAVE_PTHREAD_NP_H
103 #include <pthread_np.h>
104 #endif
105 #include <sys/time.h>
106 #include <time.h>
107 #include <errno.h>
109 #define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0)
111 typedef pthread_mutex_t CRITICAL_SECTION;
112 void InitializeCriticalSection(CRITICAL_SECTION *cs);
113 void DeleteCriticalSection(CRITICAL_SECTION *cs);
114 void EnterCriticalSection(CRITICAL_SECTION *cs);
115 void LeaveCriticalSection(CRITICAL_SECTION *cs);
117 ALuint timeGetTime(void);
118 void Sleep(ALuint t);
120 #if defined(HAVE_DLFCN_H)
121 #define HAVE_DYNLOAD 1
122 void *LoadLib(const char *name);
123 void CloseLib(void *handle);
124 void *GetSymbol(void *handle, const char *name);
125 #endif
127 #endif
129 typedef void *volatile XchgPtr;
131 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
132 typedef ALuint RefCount;
133 static __inline RefCount IncrementRef(volatile RefCount *ptr)
134 { return __sync_add_and_fetch(ptr, 1); }
135 static __inline RefCount DecrementRef(volatile RefCount *ptr)
136 { return __sync_sub_and_fetch(ptr, 1); }
138 static __inline int ExchangeInt(volatile int *ptr, int newval)
140 return __sync_lock_test_and_set(ptr, newval);
142 static __inline void *ExchangePtr(XchgPtr *ptr, void *newval)
144 return __sync_lock_test_and_set(ptr, newval);
146 static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
148 return __sync_bool_compare_and_swap(ptr, oldval, newval);
150 static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval)
152 return __sync_bool_compare_and_swap(ptr, oldval, newval);
155 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
157 static __inline int xaddl(volatile int *dest, int incr)
159 int ret;
160 __asm__ __volatile__("lock; xaddl %0,(%1)"
161 : "=r" (ret)
162 : "r" (dest), "0" (incr)
163 : "memory");
164 return ret;
167 typedef int RefCount;
168 static __inline RefCount IncrementRef(volatile RefCount *ptr)
169 { return xaddl(ptr, 1)+1; }
170 static __inline RefCount DecrementRef(volatile RefCount *ptr)
171 { return xaddl(ptr, -1)-1; }
173 static __inline int ExchangeInt(volatile int *dest, int newval)
175 int ret;
176 __asm__ __volatile__("lock; xchgl %0,(%1)"
177 : "=r" (ret)
178 : "r" (dest), "0" (newval)
179 : "memory");
180 return ret;
183 static __inline ALboolean CompExchangeInt(volatile int *dest, int oldval, int newval)
185 int ret;
186 __asm__ __volatile__("lock; cmpxchgl %2,(%1)"
187 : "=a" (ret)
188 : "r" (dest), "r" (newval), "0" (oldval)
189 : "memory");
190 return ret == oldval;
193 static __inline void *ExchangePtr(XchgPtr *dest, void *newval)
195 void *ret;
196 __asm__ __volatile__(
197 #ifdef __i386__
198 "lock; xchgl %0,(%1)"
199 #else
200 "lock; xchgq %0,(%1)"
201 #endif
202 : "=r" (ret)
203 : "r" (dest), "0" (newval)
204 : "memory"
206 return ret;
209 static __inline ALboolean CompExchangePtr(XchgPtr *dest, void *oldval, void *newval)
211 void *ret;
212 __asm__ __volatile__(
213 #ifdef __i386__
214 "lock; cmpxchgl %2,(%1)"
215 #else
216 "lock; cmpxchgq %2,(%1)"
217 #endif
218 : "=a" (ret)
219 : "r" (dest), "r" (newval), "0" (oldval)
220 : "memory"
222 return ret == oldval;
225 #elif defined(_WIN32)
227 typedef LONG RefCount;
228 static __inline RefCount IncrementRef(volatile RefCount *ptr)
229 { return InterlockedIncrement(ptr); }
230 static __inline RefCount DecrementRef(volatile RefCount *ptr)
231 { return InterlockedDecrement(ptr); }
233 extern ALbyte LONG_size_does_not_match_int[(sizeof(LONG)==sizeof(int))?1:-1];
235 static __inline int ExchangeInt(volatile int *ptr, int newval)
237 union {
238 volatile int *i;
239 volatile LONG *l;
240 } u = { ptr };
241 return InterlockedExchange(u.l, newval);
243 static __inline void *ExchangePtr(XchgPtr *ptr, void *newval)
245 return InterlockedExchangePointer(ptr, newval);
247 static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
249 union {
250 volatile int *i;
251 volatile LONG *l;
252 } u = { ptr };
253 return InterlockedCompareExchange(u.l, newval, oldval) == oldval;
255 static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval)
257 return InterlockedCompareExchangePointer(ptr, newval, oldval) == oldval;
260 #elif defined(__APPLE__)
262 #include <libkern/OSAtomic.h>
264 typedef int32_t RefCount;
265 static __inline RefCount IncrementRef(volatile RefCount *ptr)
266 { return OSAtomicIncrement32Barrier(ptr); }
267 static __inline RefCount DecrementRef(volatile RefCount *ptr)
268 { return OSAtomicDecrement32Barrier(ptr); }
270 static __inline int ExchangeInt(volatile int *ptr, int newval)
272 /* Really? No regular old atomic swap? */
273 int oldval;
274 do {
275 oldval = *ptr;
276 } while(!OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr));
277 return oldval;
279 static __inline void *ExchangePtr(XchgPtr *ptr, void *newval)
281 void *oldval;
282 do {
283 oldval = *ptr;
284 } while(!OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr));
285 return oldval;
287 static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
289 return OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr);
291 static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval)
293 return OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr);
296 #else
297 #error "No atomic functions available on this platform!"
298 typedef ALuint RefCount;
299 #endif
302 typedef struct {
303 volatile RefCount read_count;
304 volatile RefCount write_count;
305 volatile ALenum read_lock;
306 volatile ALenum read_entry_lock;
307 volatile ALenum write_lock;
308 } RWLock;
310 void RWLockInit(RWLock *lock);
311 void ReadLock(RWLock *lock);
312 void ReadUnlock(RWLock *lock);
313 void WriteLock(RWLock *lock);
314 void WriteUnlock(RWLock *lock);
317 typedef struct UIntMap {
318 struct {
319 ALuint key;
320 ALvoid *value;
321 } *array;
322 ALsizei size;
323 ALsizei maxsize;
324 ALsizei limit;
325 RWLock lock;
326 } UIntMap;
327 extern UIntMap TlsDestructor;
329 void InitUIntMap(UIntMap *map, ALsizei limit);
330 void ResetUIntMap(UIntMap *map);
331 ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
332 ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);
333 ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
335 static __inline void LockUIntMapRead(UIntMap *map)
336 { ReadLock(&map->lock); }
337 static __inline void UnlockUIntMapRead(UIntMap *map)
338 { ReadUnlock(&map->lock); }
339 static __inline void LockUIntMapWrite(UIntMap *map)
340 { WriteLock(&map->lock); }
341 static __inline void UnlockUIntMapWrite(UIntMap *map)
342 { WriteUnlock(&map->lock); }
344 #include "alListener.h"
345 #include "alu.h"
347 #ifdef __cplusplus
348 extern "C" {
349 #endif
352 #define DEFAULT_OUTPUT_RATE (44100)
353 #define MIN_OUTPUT_RATE (8000)
355 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
356 #define AIRABSORBGAINHF (0.99426f) /* -0.05dB */
358 #define LOWPASSFREQREF (5000)
361 struct Hrtf;
364 // Find the next power-of-2 for non-power-of-2 numbers.
365 static __inline ALuint NextPowerOf2(ALuint value)
367 ALuint powerOf2 = 1;
369 if(value)
371 value--;
372 while(value)
374 value >>= 1;
375 powerOf2 <<= 1;
378 return powerOf2;
381 /* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
382 * mode. */
383 static __inline ALint fastf2i(ALfloat f)
385 ALint i;
386 #if defined(_MSC_VER) && defined(_M_IX86)
387 __asm fld f
388 __asm fistp i
389 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
390 __asm__ __volatile__("flds %1\n\t"
391 "fistpl %0\n\t"
392 : "=m" (i)
393 : "m" (f));
394 #else
395 i = (ALint)f;
396 #endif
397 return i;
400 /* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
401 * mode. */
402 static __inline ALuint fastf2u(ALfloat f)
403 { return fastf2i(f); }
406 enum DevProbe {
407 ALL_DEVICE_PROBE,
408 CAPTURE_DEVICE_PROBE
411 typedef struct {
412 ALCenum (*OpenPlayback)(ALCdevice*, const ALCchar*);
413 void (*ClosePlayback)(ALCdevice*);
414 ALCboolean (*ResetPlayback)(ALCdevice*);
415 ALCboolean (*StartPlayback)(ALCdevice*);
416 void (*StopPlayback)(ALCdevice*);
418 ALCenum (*OpenCapture)(ALCdevice*, const ALCchar*);
419 void (*CloseCapture)(ALCdevice*);
420 void (*StartCapture)(ALCdevice*);
421 void (*StopCapture)(ALCdevice*);
422 ALCenum (*CaptureSamples)(ALCdevice*, void*, ALCuint);
423 ALCuint (*AvailableSamples)(ALCdevice*);
424 } BackendFuncs;
426 struct BackendInfo {
427 const char *name;
428 ALCboolean (*Init)(BackendFuncs*);
429 void (*Deinit)(void);
430 void (*Probe)(enum DevProbe);
431 BackendFuncs Funcs;
434 ALCboolean alc_alsa_init(BackendFuncs *func_list);
435 void alc_alsa_deinit(void);
436 void alc_alsa_probe(enum DevProbe type);
437 ALCboolean alc_oss_init(BackendFuncs *func_list);
438 void alc_oss_deinit(void);
439 void alc_oss_probe(enum DevProbe type);
440 ALCboolean alc_solaris_init(BackendFuncs *func_list);
441 void alc_solaris_deinit(void);
442 void alc_solaris_probe(enum DevProbe type);
443 ALCboolean alc_sndio_init(BackendFuncs *func_list);
444 void alc_sndio_deinit(void);
445 void alc_sndio_probe(enum DevProbe type);
446 ALCboolean alcMMDevApiInit(BackendFuncs *func_list);
447 void alcMMDevApiDeinit(void);
448 void alcMMDevApiProbe(enum DevProbe type);
449 ALCboolean alcDSoundInit(BackendFuncs *func_list);
450 void alcDSoundDeinit(void);
451 void alcDSoundProbe(enum DevProbe type);
452 ALCboolean alcWinMMInit(BackendFuncs *FuncList);
453 void alcWinMMDeinit(void);
454 void alcWinMMProbe(enum DevProbe type);
455 ALCboolean alc_pa_init(BackendFuncs *func_list);
456 void alc_pa_deinit(void);
457 void alc_pa_probe(enum DevProbe type);
458 ALCboolean alc_wave_init(BackendFuncs *func_list);
459 void alc_wave_deinit(void);
460 void alc_wave_probe(enum DevProbe type);
461 ALCboolean alc_pulse_init(BackendFuncs *func_list);
462 void alc_pulse_deinit(void);
463 void alc_pulse_probe(enum DevProbe type);
464 ALCboolean alc_ca_init(BackendFuncs *func_list);
465 void alc_ca_deinit(void);
466 void alc_ca_probe(enum DevProbe type);
467 ALCboolean alc_opensl_init(BackendFuncs *func_list);
468 void alc_opensl_deinit(void);
469 void alc_opensl_probe(enum DevProbe type);
470 ALCboolean alc_null_init(BackendFuncs *func_list);
471 void alc_null_deinit(void);
472 void alc_null_probe(enum DevProbe type);
473 ALCboolean alc_loopback_init(BackendFuncs *func_list);
474 void alc_loopback_deinit(void);
475 void alc_loopback_probe(enum DevProbe type);
478 /* Device formats */
479 enum DevFmtType {
480 DevFmtByte = ALC_BYTE_SOFT,
481 DevFmtUByte = ALC_UNSIGNED_BYTE_SOFT,
482 DevFmtShort = ALC_SHORT_SOFT,
483 DevFmtUShort = ALC_UNSIGNED_SHORT_SOFT,
484 DevFmtInt = ALC_INT_SOFT,
485 DevFmtUInt = ALC_UNSIGNED_INT_SOFT,
486 DevFmtFloat = ALC_FLOAT_SOFT,
488 DevFmtTypeDefault = DevFmtFloat
490 enum DevFmtChannels {
491 DevFmtMono = ALC_MONO_SOFT,
492 DevFmtStereo = ALC_STEREO_SOFT,
493 DevFmtQuad = ALC_QUAD_SOFT,
494 DevFmtX51 = ALC_5POINT1_SOFT,
495 DevFmtX61 = ALC_6POINT1_SOFT,
496 DevFmtX71 = ALC_7POINT1_SOFT,
498 /* Similar to 5.1, except using the side channels instead of back */
499 DevFmtX51Side = 0x80000000,
501 DevFmtChannelsDefault = DevFmtStereo
504 ALuint BytesFromDevFmt(enum DevFmtType type);
505 ALuint ChannelsFromDevFmt(enum DevFmtChannels chans);
506 static __inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans,
507 enum DevFmtType type)
509 return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type);
513 extern const struct EffectList {
514 const char *name;
515 int type;
516 const char *ename;
517 ALenum val;
518 } EffectList[];
521 enum DeviceType {
522 Playback,
523 Capture,
524 Loopback
527 struct ALCdevice_struct
529 volatile RefCount ref;
531 ALCboolean Connected;
532 enum DeviceType Type;
534 CRITICAL_SECTION Mutex;
536 ALuint Frequency;
537 ALuint UpdateSize;
538 ALuint NumUpdates;
539 enum DevFmtChannels FmtChans;
540 enum DevFmtType FmtType;
542 ALCchar *szDeviceName;
544 volatile ALCenum LastError;
546 // Maximum number of sources that can be created
547 ALuint MaxNoOfSources;
548 // Maximum number of slots that can be created
549 ALuint AuxiliaryEffectSlotMax;
551 ALCuint NumMonoSources;
552 ALCuint NumStereoSources;
553 ALuint NumAuxSends;
555 // Map of Buffers for this device
556 UIntMap BufferMap;
558 // Map of Effects for this device
559 UIntMap EffectMap;
561 // Map of Filters for this device
562 UIntMap FilterMap;
564 /* HRTF filter tables */
565 const struct Hrtf *Hrtf;
567 // Stereo-to-binaural filter
568 struct bs2b *Bs2b;
569 ALCint Bs2bLevel;
571 // Device flags
572 ALuint Flags;
574 // Dry path buffer mix
575 ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS];
577 enum Channel DevChannels[MAXCHANNELS];
579 enum Channel Speaker2Chan[MAXCHANNELS];
580 ALfloat PanningLUT[LUT_NUM][MAXCHANNELS];
581 ALuint NumChan;
583 ALfloat ClickRemoval[MAXCHANNELS];
584 ALfloat PendingClicks[MAXCHANNELS];
586 /* Default effect slot */
587 struct ALeffectslot *DefaultSlot;
589 // Contexts created on this device
590 ALCcontext *volatile ContextList;
592 BackendFuncs *Funcs;
593 void *ExtraData; // For the backend's use
595 ALCdevice *volatile next;
598 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
599 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
600 #define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
601 #define ALCdevice_StartPlayback(a) ((a)->Funcs->StartPlayback((a)))
602 #define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
603 #define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
604 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
605 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
606 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
607 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
608 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
610 // Duplicate stereo sources on the side/rear channels
611 #define DEVICE_DUPLICATE_STEREO (1<<0)
612 // Frequency was requested by the app or config file
613 #define DEVICE_FREQUENCY_REQUEST (1<<1)
614 // Channel configuration was requested by the config file
615 #define DEVICE_CHANNELS_REQUEST (1<<2)
616 // Sample type was requested by the config file
617 #define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
619 // Specifies if the device is currently running
620 #define DEVICE_RUNNING (1<<31)
622 #define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k)))
623 #define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k)))
624 #define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k)))
625 #define RemoveBuffer(m, k) ((struct ALbuffer*)RemoveUIntMapKey(&(m)->BufferMap, (k)))
626 #define RemoveEffect(m, k) ((struct ALeffect*)RemoveUIntMapKey(&(m)->EffectMap, (k)))
627 #define RemoveFilter(m, k) ((struct ALfilter*)RemoveUIntMapKey(&(m)->FilterMap, (k)))
630 struct ALCcontext_struct
632 volatile RefCount ref;
634 ALlistener Listener;
636 UIntMap SourceMap;
637 UIntMap EffectSlotMap;
639 ALenum LastError;
641 volatile ALenum UpdateSources;
643 volatile enum DistanceModel DistanceModel;
644 volatile ALboolean SourceDistanceModel;
646 volatile ALfloat DopplerFactor;
647 volatile ALfloat DopplerVelocity;
648 volatile ALfloat flSpeedOfSound;
649 volatile ALenum DeferUpdates;
651 struct ALsource **ActiveSources;
652 ALsizei ActiveSourceCount;
653 ALsizei MaxActiveSources;
655 struct ALeffectslot **ActiveEffectSlots;
656 ALsizei ActiveEffectSlotCount;
657 ALsizei MaxActiveEffectSlots;
659 ALCdevice *Device;
660 const ALCchar *ExtensionList;
662 ALCcontext *volatile next;
665 #define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k)))
666 #define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k)))
667 #define RemoveSource(m, k) ((struct ALsource*)RemoveUIntMapKey(&(m)->SourceMap, (k)))
668 #define RemoveEffectSlot(m, k) ((struct ALeffectslot*)RemoveUIntMapKey(&(m)->EffectSlotMap, (k)))
670 ALCcontext *GetContextRef(void);
672 void ALCcontext_IncRef(ALCcontext *context);
673 void ALCcontext_DecRef(ALCcontext *context);
675 void AppendAllDeviceList(const ALCchar *name);
676 void AppendCaptureDeviceList(const ALCchar *name);
678 static __inline void LockDevice(ALCdevice *device)
679 { EnterCriticalSection(&device->Mutex); }
680 static __inline void UnlockDevice(ALCdevice *device)
681 { LeaveCriticalSection(&device->Mutex); }
683 static __inline void LockContext(ALCcontext *context)
684 { LockDevice(context->Device); }
685 static __inline void UnlockContext(ALCcontext *context)
686 { UnlockDevice(context->Device); }
689 ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
690 ALuint StopThread(ALvoid *thread);
692 typedef struct RingBuffer RingBuffer;
693 RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
694 void DestroyRingBuffer(RingBuffer *ring);
695 ALsizei RingBufferSize(RingBuffer *ring);
696 void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
697 void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
699 void ReadALConfig(void);
700 void FreeALConfig(void);
701 int ConfigValueExists(const char *blockName, const char *keyName);
702 const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
703 int GetConfigValueBool(const char *blockName, const char *keyName, int def);
704 int ConfigValueStr(const char *blockName, const char *keyName, const char **ret);
705 int ConfigValueInt(const char *blockName, const char *keyName, int *ret);
706 int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret);
707 int ConfigValueFloat(const char *blockName, const char *keyName, float *ret);
709 void SetRTPriority(void);
711 void SetDefaultChannelOrder(ALCdevice *device);
712 void SetDefaultWFXChannelOrder(ALCdevice *device);
714 const ALCchar *DevFmtTypeString(enum DevFmtType type);
715 const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans);
717 #define HRIR_BITS (5)
718 #define HRIR_LENGTH (1<<HRIR_BITS)
719 #define HRIR_MASK (HRIR_LENGTH-1)
720 void InitHrtf(void);
721 void FreeHrtf(void);
722 const struct Hrtf *GetHrtf(ALCdevice *device);
723 ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]);
724 void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays);
725 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);
727 void al_print(const char *func, const char *fmt, ...) PRINTF_STYLE(2,3);
728 #define AL_PRINT(...) al_print(__FUNCTION__, __VA_ARGS__)
730 extern FILE *LogFile;
731 enum LogLevel {
732 NoLog,
733 LogError,
734 LogWarning,
735 LogTrace,
736 LogRef
738 extern enum LogLevel LogLevel;
740 #define TRACEREF(...) do { \
741 if(LogLevel >= LogRef) \
742 AL_PRINT(__VA_ARGS__); \
743 } while(0)
745 #define TRACE(...) do { \
746 if(LogLevel >= LogTrace) \
747 AL_PRINT(__VA_ARGS__); \
748 } while(0)
750 #define WARN(...) do { \
751 if(LogLevel >= LogWarning) \
752 AL_PRINT(__VA_ARGS__); \
753 } while(0)
755 #define ERR(...) do { \
756 if(LogLevel >= LogError) \
757 AL_PRINT(__VA_ARGS__); \
758 } while(0)
761 extern ALint RTPrioLevel;
763 #ifdef __cplusplus
765 #endif
767 #endif