Store the HRTF tables used in the device
[openal-soft/android.git] / OpenAL32 / Include / alMain.h
bloba5a96e8187ef52a7011a17a917f83d62d1687acf
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 #include "AL/al.h"
13 #include "AL/alc.h"
14 #include "AL/alext.h"
16 #ifndef ALC_SOFT_device_loopback
17 #define ALC_SOFT_device_loopback 1
18 #define ALC_FORMAT_CHANNELS_SOFT 0x1990
19 #define ALC_FORMAT_TYPE_SOFT 0x1991
21 /* Sample types */
22 #define ALC_BYTE 0x1400
23 #define ALC_UNSIGNED_BYTE 0x1401
24 #define ALC_SHORT 0x1402
25 #define ALC_UNSIGNED_SHORT 0x1403
26 #define ALC_INT 0x1404
27 #define ALC_UNSIGNED_INT 0x1405
28 #define ALC_FLOAT 0x1406
30 /* Channel configurations */
31 #define ALC_MONO 0x1500
32 #define ALC_STEREO 0x1501
33 #define ALC_QUAD 0x1503
34 #define ALC_5POINT1 0x1504 /* (WFX order) */
35 #define ALC_6POINT1 0x1505 /* (WFX order) */
36 #define ALC_7POINT1 0x1506 /* (WFX order) */
38 typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(void);
39 typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type);
40 typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
41 #ifdef AL_ALEXT_PROTOTYPES
42 ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void);
43 ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type);
44 ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
45 #endif
46 #endif
48 #ifndef AL_SOFT_buffer_samples
49 #define AL_SOFT_buffer_samples 1
50 /* Sample types */
51 #define AL_BYTE 0x1400
52 #define AL_UNSIGNED_BYTE 0x1401
53 #define AL_SHORT 0x1402
54 #define AL_UNSIGNED_SHORT 0x1403
55 #define AL_INT 0x1404
56 #define AL_UNSIGNED_INT 0x1405
57 #define AL_FLOAT 0x1406
58 #define AL_DOUBLE 0x1407
59 #define AL_BYTE3 0x1408
60 #define AL_UNSIGNED_BYTE3 0x1409
61 #define AL_MULAW 0x1410
62 #define AL_IMA4 0x1411
64 /* Channel configurations */
65 #define AL_MONO 0x1500
66 #define AL_STEREO 0x1501
67 #define AL_REAR 0x1502
68 #define AL_QUAD 0x1503
69 #define AL_5POINT1 0x1504 /* (WFX order) */
70 #define AL_6POINT1 0x1505 /* (WFX order) */
71 #define AL_7POINT1 0x1506 /* (WFX order) */
73 /* Storage formats */
74 #define AL_MONO8 0x1100
75 #define AL_MONO16 0x1101
76 #define AL_MONO32F 0x10010
77 #define AL_STEREO8 0x1102
78 #define AL_STEREO16 0x1103
79 #define AL_STEREO32F 0x10011
80 #define AL_QUAD8 0x1204
81 #define AL_QUAD16 0x1205
82 #define AL_QUAD32F 0x1206
83 #define AL_REAR8 0x1207
84 #define AL_REAR16 0x1208
85 #define AL_REAR32F 0x1209
86 #define AL_5POINT1_8 0x120A
87 #define AL_5POINT1_16 0x120B
88 #define AL_5POINT1_32F 0x120C
89 #define AL_6POINT1_8 0x120D
90 #define AL_6POINT1_16 0x120E
91 #define AL_6POINT1_32F 0x120F
92 #define AL_7POINT1_8 0x1210
93 #define AL_7POINT1_16 0x1211
94 #define AL_7POINT1_32F 0x1212
96 typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
97 typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
98 typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
99 typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum);
100 #ifdef AL_ALEXT_PROTOTYPES
101 AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
102 ALuint samplerate, ALenum internalformat, ALsizei frames,
103 ALenum channels, ALenum type, const ALvoid *data);
104 AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
105 ALsizei offset, ALsizei frames,
106 ALenum channels, ALenum type, const ALvoid *data);
107 AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer,
108 ALsizei offset, ALsizei frames,
109 ALenum channels, ALenum type, ALvoid *data);
110 AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format);
111 #endif
112 #endif
114 #ifndef AL_SOFT_non_virtual_channels
115 #define AL_SOFT_non_virtual_channels 1
116 #define AL_VIRTUAL_CHANNELS_SOFT 0x1033
117 #endif
119 #ifndef AL_SOFT_deferred_updates
120 #define AL_SOFT_deferred_updates 1
121 #define AL_DEFERRED_UPDATES_SOFT 0xC002
122 typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void);
123 typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void);
124 #ifdef AL_ALEXT_PROTOTYPES
125 AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void);
126 AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void);
127 #endif
128 #endif
131 #if defined(HAVE_STDINT_H)
132 #include <stdint.h>
133 typedef int64_t ALint64;
134 typedef uint64_t ALuint64;
135 #elif defined(HAVE___INT64)
136 typedef __int64 ALint64;
137 typedef unsigned __int64 ALuint64;
138 #elif (SIZEOF_LONG == 8)
139 typedef long ALint64;
140 typedef unsigned long ALuint64;
141 #elif (SIZEOF_LONG_LONG == 8)
142 typedef long long ALint64;
143 typedef unsigned long long ALuint64;
144 #endif
146 typedef ptrdiff_t ALintptrEXT;
147 typedef ptrdiff_t ALsizeiptrEXT;
149 #ifdef HAVE_GCC_FORMAT
150 #define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
151 #else
152 #define PRINTF_STYLE(x, y)
153 #endif
155 #if defined(HAVE_RESTRICT)
156 #define RESTRICT restrict
157 #elif defined(HAVE___RESTRICT)
158 #define RESTRICT __restrict
159 #else
160 #define RESTRICT
161 #endif
164 #ifdef _WIN32
166 #ifndef _WIN32_WINNT
167 #define _WIN32_WINNT 0x0500
168 #endif
169 #include <windows.h>
171 typedef DWORD pthread_key_t;
172 int pthread_key_create(pthread_key_t *key, void (*callback)(void*));
173 int pthread_key_delete(pthread_key_t key);
174 void *pthread_getspecific(pthread_key_t key);
175 int pthread_setspecific(pthread_key_t key, void *val);
177 #define HAVE_DYNLOAD 1
178 void *LoadLib(const char *name);
179 void CloseLib(void *handle);
180 void *GetSymbol(void *handle, const char *name);
182 typedef LONG pthread_once_t;
183 #define PTHREAD_ONCE_INIT 0
184 void pthread_once(pthread_once_t *once, void (*callback)(void));
186 #else
188 #include <unistd.h>
189 #include <assert.h>
190 #include <pthread.h>
191 #ifdef HAVE_PTHREAD_NP_H
192 #include <pthread_np.h>
193 #endif
194 #include <sys/time.h>
195 #include <time.h>
196 #include <errno.h>
198 #define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0)
200 typedef pthread_mutex_t CRITICAL_SECTION;
201 void InitializeCriticalSection(CRITICAL_SECTION *cs);
202 void DeleteCriticalSection(CRITICAL_SECTION *cs);
203 void EnterCriticalSection(CRITICAL_SECTION *cs);
204 void LeaveCriticalSection(CRITICAL_SECTION *cs);
206 ALuint timeGetTime(void);
208 static __inline void Sleep(ALuint t)
210 struct timespec tv, rem;
211 tv.tv_nsec = (t*1000000)%1000000000;
212 tv.tv_sec = t/1000;
214 while(nanosleep(&tv, &rem) == -1 && errno == EINTR)
215 tv = rem;
218 #if defined(HAVE_DLFCN_H)
219 #define HAVE_DYNLOAD 1
220 void *LoadLib(const char *name);
221 void CloseLib(void *handle);
222 void *GetSymbol(void *handle, const char *name);
223 #endif
225 #endif
227 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
228 typedef ALuint RefCount;
229 static __inline RefCount IncrementRef(volatile RefCount *ptr)
230 { return __sync_add_and_fetch(ptr, 1); }
231 static __inline RefCount DecrementRef(volatile RefCount *ptr)
232 { return __sync_sub_and_fetch(ptr, 1); }
234 static __inline int ExchangeInt(volatile int *ptr, int newval)
236 return __sync_lock_test_and_set(ptr, newval);
238 static __inline void *ExchangePtr(void *volatile*ptr, void *newval)
240 return __sync_lock_test_and_set(ptr, newval);
242 static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
244 return __sync_bool_compare_and_swap(ptr, oldval, newval);
246 static __inline ALboolean CompExchangePtr(void *volatile*ptr, void *oldval, void *newval)
248 return __sync_bool_compare_and_swap(ptr, oldval, newval);
251 #elif defined(_WIN32)
253 typedef LONG RefCount;
254 static __inline RefCount IncrementRef(volatile RefCount *ptr)
255 { return InterlockedIncrement(ptr); }
256 static __inline RefCount DecrementRef(volatile RefCount *ptr)
257 { return InterlockedDecrement(ptr); }
259 extern ALbyte LONG_size_does_not_match_int[(sizeof(LONG)==sizeof(int))?1:-1];
261 static __inline int ExchangeInt(volatile int *ptr, int newval)
263 union {
264 volatile int *i;
265 volatile LONG *l;
266 } u = { ptr };
267 return InterlockedExchange(u.l, newval);
269 static __inline void *ExchangePtr(void *volatile*ptr, void *newval)
271 return InterlockedExchangePointer(ptr, newval);
273 static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
275 union {
276 volatile int *i;
277 volatile LONG *l;
278 } u = { ptr };
279 return InterlockedCompareExchange(u.l, newval, oldval) == oldval;
281 static __inline ALboolean CompExchangePtr(void *volatile*ptr, void *oldval, void *newval)
283 return InterlockedCompareExchangePointer(ptr, newval, oldval) == oldval;
286 #elif defined(__APPLE__)
288 #include <libkern/OSAtomic.h>
290 typedef int32_t RefCount;
291 static __inline RefCount IncrementRef(volatile RefCount *ptr)
292 { return OSAtomicIncrement32Barrier(ptr); }
293 static __inline RefCount DecrementRef(volatile RefCount *ptr)
294 { return OSAtomicDecrement32Barrier(ptr); }
296 static __inline int ExchangeInt(volatile int *ptr, int newval)
298 /* Really? No regular old atomic swap? */
299 int oldval;
300 do {
301 oldval = *ptr;
302 } while(!OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr));
303 return oldval;
305 static __inline void *ExchangePtr(void *volatile*ptr, void *newval)
307 void *oldval;
308 do {
309 oldval = *ptr;
310 } while(!OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr));
311 return oldval;
313 static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval)
315 return OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr);
317 static __inline ALboolean CompExchangePtr(void *volatile*ptr, void *oldval, void *newval)
319 return OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr);
322 #else
323 #error "No atomic functions available on this platform!"
324 typedef ALuint RefCount;
325 #endif
328 typedef struct {
329 volatile RefCount read_count;
330 volatile RefCount write_count;
331 volatile ALenum read_lock;
332 volatile ALenum read_entry_lock;
333 volatile ALenum write_lock;
334 } RWLock;
336 void RWLockInit(RWLock *lock);
337 void ReadLock(RWLock *lock);
338 void ReadUnlock(RWLock *lock);
339 void WriteLock(RWLock *lock);
340 void WriteUnlock(RWLock *lock);
343 typedef struct UIntMap {
344 struct {
345 ALuint key;
346 ALvoid *value;
347 } *array;
348 ALsizei size;
349 ALsizei maxsize;
350 ALsizei limit;
351 RWLock lock;
352 } UIntMap;
353 extern UIntMap TlsDestructor;
355 void InitUIntMap(UIntMap *map, ALsizei limit);
356 void ResetUIntMap(UIntMap *map);
357 ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
358 void RemoveUIntMapKey(UIntMap *map, ALuint key);
359 ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
360 ALvoid *PopUIntMapValue(UIntMap *map, ALuint key);
362 static __inline void LockUIntMapRead(UIntMap *map)
363 { ReadLock(&map->lock); }
364 static __inline void UnlockUIntMapRead(UIntMap *map)
365 { ReadUnlock(&map->lock); }
366 static __inline void LockUIntMapWrite(UIntMap *map)
367 { WriteLock(&map->lock); }
368 static __inline void UnlockUIntMapWrite(UIntMap *map)
369 { WriteUnlock(&map->lock); }
371 #include "alListener.h"
372 #include "alu.h"
374 #ifdef __cplusplus
375 extern "C" {
376 #endif
379 #define DEFAULT_OUTPUT_RATE (44100)
381 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
382 #define AIRABSORBGAINHF (0.99426) /* -0.05dB */
384 #define LOWPASSFREQCUTOFF (5000)
387 struct Hrtf;
390 // Find the next power-of-2 for non-power-of-2 numbers.
391 static __inline ALuint NextPowerOf2(ALuint value)
393 ALuint powerOf2 = 1;
395 if(value)
397 value--;
398 while(value)
400 value >>= 1;
401 powerOf2 <<= 1;
404 return powerOf2;
408 enum DevProbe {
409 DEVICE_PROBE,
410 ALL_DEVICE_PROBE,
411 CAPTURE_DEVICE_PROBE
414 typedef struct {
415 ALCenum (*OpenPlayback)(ALCdevice*, const ALCchar*);
416 void (*ClosePlayback)(ALCdevice*);
417 ALCboolean (*ResetPlayback)(ALCdevice*);
418 void (*StopPlayback)(ALCdevice*);
420 ALCenum (*OpenCapture)(ALCdevice*, const ALCchar*);
421 void (*CloseCapture)(ALCdevice*);
422 void (*StartCapture)(ALCdevice*);
423 void (*StopCapture)(ALCdevice*);
424 ALCenum (*CaptureSamples)(ALCdevice*, void*, ALCuint);
425 ALCuint (*AvailableSamples)(ALCdevice*);
426 } BackendFuncs;
428 struct BackendInfo {
429 const char *name;
430 ALCboolean (*Init)(BackendFuncs*);
431 void (*Deinit)(void);
432 void (*Probe)(enum DevProbe);
433 BackendFuncs Funcs;
436 ALCboolean alc_alsa_init(BackendFuncs *func_list);
437 void alc_alsa_deinit(void);
438 void alc_alsa_probe(enum DevProbe type);
439 ALCboolean alc_oss_init(BackendFuncs *func_list);
440 void alc_oss_deinit(void);
441 void alc_oss_probe(enum DevProbe type);
442 ALCboolean alc_solaris_init(BackendFuncs *func_list);
443 void alc_solaris_deinit(void);
444 void alc_solaris_probe(enum DevProbe type);
445 ALCboolean alc_sndio_init(BackendFuncs *func_list);
446 void alc_sndio_deinit(void);
447 void alc_sndio_probe(enum DevProbe type);
448 ALCboolean alcMMDevApiInit(BackendFuncs *func_list);
449 void alcMMDevApiDeinit(void);
450 void alcMMDevApiProbe(enum DevProbe type);
451 ALCboolean alcDSoundInit(BackendFuncs *func_list);
452 void alcDSoundDeinit(void);
453 void alcDSoundProbe(enum DevProbe type);
454 ALCboolean alcWinMMInit(BackendFuncs *FuncList);
455 void alcWinMMDeinit(void);
456 void alcWinMMProbe(enum DevProbe type);
457 ALCboolean alc_pa_init(BackendFuncs *func_list);
458 void alc_pa_deinit(void);
459 void alc_pa_probe(enum DevProbe type);
460 ALCboolean alc_wave_init(BackendFuncs *func_list);
461 void alc_wave_deinit(void);
462 void alc_wave_probe(enum DevProbe type);
463 ALCboolean alc_pulse_init(BackendFuncs *func_list);
464 void alc_pulse_deinit(void);
465 void alc_pulse_probe(enum DevProbe type);
466 ALCboolean alc_ca_init(BackendFuncs *func_list);
467 void alc_ca_deinit(void);
468 void alc_ca_probe(enum DevProbe type);
469 ALCboolean alc_opensl_init(BackendFuncs *func_list);
470 void alc_opensl_deinit(void);
471 void alc_opensl_probe(enum DevProbe type);
472 ALCboolean alc_null_init(BackendFuncs *func_list);
473 void alc_null_deinit(void);
474 void alc_null_probe(enum DevProbe type);
475 ALCboolean alc_loopback_init(BackendFuncs *func_list);
476 void alc_loopback_deinit(void);
477 void alc_loopback_probe(enum DevProbe type);
480 /* Device formats */
481 enum DevFmtType {
482 DevFmtByte = AL_BYTE,
483 DevFmtUByte = AL_UNSIGNED_BYTE,
484 DevFmtShort = AL_SHORT,
485 DevFmtUShort = AL_UNSIGNED_SHORT,
486 DevFmtFloat = AL_FLOAT
488 enum DevFmtChannels {
489 DevFmtMono = AL_MONO,
490 DevFmtStereo = AL_STEREO,
491 DevFmtQuad = AL_QUAD,
492 DevFmtX51 = AL_5POINT1,
493 DevFmtX61 = AL_6POINT1,
494 DevFmtX71 = AL_7POINT1,
496 /* Similar to 5.1, except using the side channels instead of back */
497 DevFmtX51Side = 0x80000000 | AL_5POINT1
500 ALuint BytesFromDevFmt(enum DevFmtType type);
501 ALuint ChannelsFromDevFmt(enum DevFmtChannels chans);
502 static __inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans,
503 enum DevFmtType type)
505 return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type);
509 extern const struct EffectList {
510 const char *name;
511 int type;
512 const char *ename;
513 ALenum val;
514 } EffectList[];
517 struct ALCdevice_struct
519 volatile RefCount ref;
521 ALCboolean Connected;
522 ALboolean IsCaptureDevice;
523 ALboolean IsLoopbackDevice;
525 CRITICAL_SECTION Mutex;
527 ALuint Frequency;
528 ALuint UpdateSize;
529 ALuint NumUpdates;
530 enum DevFmtChannels FmtChans;
531 enum DevFmtType FmtType;
533 ALCchar *szDeviceName;
535 volatile ALCenum LastError;
537 // Maximum number of sources that can be created
538 ALuint MaxNoOfSources;
539 // Maximum number of slots that can be created
540 ALuint AuxiliaryEffectSlotMax;
542 ALCuint NumMonoSources;
543 ALCuint NumStereoSources;
544 ALuint NumAuxSends;
546 // Map of Buffers for this device
547 UIntMap BufferMap;
549 // Map of Effects for this device
550 UIntMap EffectMap;
552 // Map of Filters for this device
553 UIntMap FilterMap;
555 /* HRTF filter tables */
556 const struct Hrtf *Hrtf;
558 // Stereo-to-binaural filter
559 struct bs2b *Bs2b;
560 ALCint Bs2bLevel;
562 // Device flags
563 ALuint Flags;
565 // Dry path buffer mix
566 ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS];
568 enum Channel DevChannels[MAXCHANNELS];
570 enum Channel Speaker2Chan[MAXCHANNELS];
571 ALfloat PanningLUT[LUT_NUM][MAXCHANNELS];
572 ALuint NumChan;
574 ALfloat ClickRemoval[MAXCHANNELS];
575 ALfloat PendingClicks[MAXCHANNELS];
577 // Contexts created on this device
578 ALCcontext *volatile ContextList;
580 BackendFuncs *Funcs;
581 void *ExtraData; // For the backend's use
583 ALCdevice *volatile next;
586 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
587 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
588 #define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
589 #define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
590 #define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
591 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
592 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
593 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
594 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
595 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
597 // Duplicate stereo sources on the side/rear channels
598 #define DEVICE_DUPLICATE_STEREO (1<<0)
599 // Use HRTF filters for mixing sounds
600 #define DEVICE_USE_HRTF (1<<1)
601 // Frequency was requested by the app or config file
602 #define DEVICE_FREQUENCY_REQUEST (1<<2)
603 // Channel configuration was requested by the config file
604 #define DEVICE_CHANNELS_REQUEST (1<<3)
606 // Specifies if the device is currently running
607 #define DEVICE_RUNNING (1<<31)
609 struct ALCcontext_struct
611 volatile RefCount ref;
613 ALlistener Listener;
615 UIntMap SourceMap;
616 UIntMap EffectSlotMap;
618 ALenum LastError;
620 volatile ALenum UpdateSources;
622 volatile enum DistanceModel DistanceModel;
623 volatile ALboolean SourceDistanceModel;
625 volatile ALfloat DopplerFactor;
626 volatile ALfloat DopplerVelocity;
627 volatile ALfloat flSpeedOfSound;
628 volatile ALenum DeferUpdates;
630 struct ALsource **ActiveSources;
631 ALsizei ActiveSourceCount;
632 ALsizei MaxActiveSources;
634 struct ALeffectslot **ActiveEffectSlots;
635 ALsizei ActiveEffectSlotCount;
636 ALsizei MaxActiveEffectSlots;
638 ALCdevice *Device;
639 const ALCchar *ExtensionList;
641 ALCcontext *volatile next;
644 ALCcontext *GetContextRef(void);
646 void ALCcontext_IncRef(ALCcontext *context);
647 void ALCcontext_DecRef(ALCcontext *context);
649 void AppendDeviceList(const ALCchar *name);
650 void AppendAllDeviceList(const ALCchar *name);
651 void AppendCaptureDeviceList(const ALCchar *name);
653 ALCvoid LockDevice(ALCdevice *device);
654 ALCvoid UnlockDevice(ALCdevice *device);
655 ALCvoid LockContext(ALCcontext *context);
656 ALCvoid UnlockContext(ALCcontext *context);
658 ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
659 ALuint StopThread(ALvoid *thread);
661 typedef struct RingBuffer RingBuffer;
662 RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
663 void DestroyRingBuffer(RingBuffer *ring);
664 ALsizei RingBufferSize(RingBuffer *ring);
665 void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
666 void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
668 void ReadALConfig(void);
669 void FreeALConfig(void);
670 int ConfigValueExists(const char *blockName, const char *keyName);
671 const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
672 int GetConfigValueInt(const char *blockName, const char *keyName, int def);
673 float GetConfigValueFloat(const char *blockName, const char *keyName, float def);
674 int GetConfigValueBool(const char *blockName, const char *keyName, int def);
676 void SetRTPriority(void);
678 void SetDefaultChannelOrder(ALCdevice *device);
679 void SetDefaultWFXChannelOrder(ALCdevice *device);
681 const ALCchar *DevFmtTypeString(enum DevFmtType type);
682 const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans);
684 #define HRIR_BITS (5)
685 #define HRIR_LENGTH (1<<HRIR_BITS)
686 #define HRIR_MASK (HRIR_LENGTH-1)
687 void InitHrtf(void);
688 const struct Hrtf *GetHrtf(ALCdevice *device);
689 ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]);
690 void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays);
691 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);
693 void al_print(const char *func, const char *fmt, ...) PRINTF_STYLE(2,3);
694 #define AL_PRINT(...) al_print(__FUNCTION__, __VA_ARGS__)
696 extern FILE *LogFile;
697 enum LogLevel {
698 NoLog,
699 LogError,
700 LogWarning,
701 LogTrace
703 extern enum LogLevel LogLevel;
705 #define TRACE(...) do { \
706 if(LogLevel >= LogTrace) \
707 AL_PRINT(__VA_ARGS__); \
708 } while(0)
710 #define WARN(...) do { \
711 if(LogLevel >= LogWarning) \
712 AL_PRINT(__VA_ARGS__); \
713 } while(0)
715 #define ERR(...) do { \
716 if(LogLevel >= LogError) \
717 AL_PRINT(__VA_ARGS__); \
718 } while(0)
721 extern ALdouble ConeScale;
722 extern ALdouble ZScale;
724 extern ALint RTPrioLevel;
726 #ifdef __cplusplus
728 #endif
730 #endif