annotate OpenAL32/Include/alMain.h @ 6:99df34265b40

disabled the user's ability to select backend since there is only one backend
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 13:25:47 -0700
parents 96298d83959c
children
rev   line source
rlm@0 1 #ifndef AL_MAIN_H
rlm@0 2 #define AL_MAIN_H
rlm@0 3
rlm@0 4 #include <string.h>
rlm@0 5 #include <stdio.h>
rlm@0 6 #include <stdarg.h>
rlm@0 7
rlm@0 8 #ifdef HAVE_FENV_H
rlm@0 9 #include <fenv.h>
rlm@0 10 #endif
rlm@0 11
rlm@0 12 #include "AL/al.h"
rlm@0 13 #include "AL/alc.h"
rlm@0 14 #include "AL/alext.h"
rlm@0 15
rlm@0 16 #ifndef ALC_SOFT_device_loopback
rlm@0 17 #define ALC_SOFT_device_loopback 1
rlm@0 18 #define ALC_FORMAT_CHANNELS_SOFT 0x1990
rlm@0 19 #define ALC_FORMAT_TYPE_SOFT 0x1991
rlm@0 20
rlm@0 21 /* Sample types */
rlm@0 22 #define ALC_BYTE 0x1400
rlm@0 23 #define ALC_UNSIGNED_BYTE 0x1401
rlm@0 24 #define ALC_SHORT 0x1402
rlm@0 25 #define ALC_UNSIGNED_SHORT 0x1403
rlm@0 26 #define ALC_INT 0x1404
rlm@0 27 #define ALC_UNSIGNED_INT 0x1405
rlm@0 28 #define ALC_FLOAT 0x1406
rlm@0 29
rlm@0 30 /* Channel configurations */
rlm@0 31 #define ALC_MONO 0x1500
rlm@0 32 #define ALC_STEREO 0x1501
rlm@0 33 #define ALC_QUAD 0x1503
rlm@0 34 #define ALC_5POINT1 0x1504 /* (WFX order) */
rlm@0 35 #define ALC_6POINT1 0x1505 /* (WFX order) */
rlm@0 36 #define ALC_7POINT1 0x1506 /* (WFX order) */
rlm@0 37
rlm@0 38 typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(void);
rlm@0 39 typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type);
rlm@0 40 typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
rlm@0 41 #ifdef AL_ALEXT_PROTOTYPES
rlm@0 42 ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(void);
rlm@0 43 ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type);
rlm@0 44 ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);
rlm@0 45 #endif
rlm@0 46 #endif
rlm@0 47
rlm@0 48 #ifndef AL_SOFT_buffer_samples
rlm@0 49 #define AL_SOFT_buffer_samples 1
rlm@0 50 /* Sample types */
rlm@0 51 #define AL_BYTE 0x1400
rlm@0 52 #define AL_UNSIGNED_BYTE 0x1401
rlm@0 53 #define AL_SHORT 0x1402
rlm@0 54 #define AL_UNSIGNED_SHORT 0x1403
rlm@0 55 #define AL_INT 0x1404
rlm@0 56 #define AL_UNSIGNED_INT 0x1405
rlm@0 57 #define AL_FLOAT 0x1406
rlm@0 58 #define AL_DOUBLE 0x1407
rlm@0 59 #define AL_BYTE3 0x1408
rlm@0 60 #define AL_UNSIGNED_BYTE3 0x1409
rlm@0 61 #define AL_MULAW 0x1410
rlm@0 62 #define AL_IMA4 0x1411
rlm@0 63
rlm@0 64 /* Channel configurations */
rlm@0 65 #define AL_MONO 0x1500
rlm@0 66 #define AL_STEREO 0x1501
rlm@0 67 #define AL_REAR 0x1502
rlm@0 68 #define AL_QUAD 0x1503
rlm@0 69 #define AL_5POINT1 0x1504 /* (WFX order) */
rlm@0 70 #define AL_6POINT1 0x1505 /* (WFX order) */
rlm@0 71 #define AL_7POINT1 0x1506 /* (WFX order) */
rlm@0 72
rlm@0 73 /* Storage formats */
rlm@0 74 #define AL_MONO8 0x1100
rlm@0 75 #define AL_MONO16 0x1101
rlm@0 76 #define AL_MONO32F 0x10010
rlm@0 77 #define AL_STEREO8 0x1102
rlm@0 78 #define AL_STEREO16 0x1103
rlm@0 79 #define AL_STEREO32F 0x10011
rlm@0 80 #define AL_QUAD8 0x1204
rlm@0 81 #define AL_QUAD16 0x1205
rlm@0 82 #define AL_QUAD32F 0x1206
rlm@0 83 #define AL_REAR8 0x1207
rlm@0 84 #define AL_REAR16 0x1208
rlm@0 85 #define AL_REAR32F 0x1209
rlm@0 86 #define AL_5POINT1_8 0x120A
rlm@0 87 #define AL_5POINT1_16 0x120B
rlm@0 88 #define AL_5POINT1_32F 0x120C
rlm@0 89 #define AL_6POINT1_8 0x120D
rlm@0 90 #define AL_6POINT1_16 0x120E
rlm@0 91 #define AL_6POINT1_32F 0x120F
rlm@0 92 #define AL_7POINT1_8 0x1210
rlm@0 93 #define AL_7POINT1_16 0x1211
rlm@0 94 #define AL_7POINT1_32F 0x1212
rlm@0 95
rlm@0 96 typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
rlm@0 97 typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
rlm@0 98 typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
rlm@0 99 typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum);
rlm@0 100 #ifdef AL_ALEXT_PROTOTYPES
rlm@0 101 AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
rlm@0 102 ALuint samplerate, ALenum internalformat, ALsizei frames,
rlm@0 103 ALenum channels, ALenum type, const ALvoid *data);
rlm@0 104 AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
rlm@0 105 ALsizei offset, ALsizei frames,
rlm@0 106 ALenum channels, ALenum type, const ALvoid *data);
rlm@0 107 AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer,
rlm@0 108 ALsizei offset, ALsizei frames,
rlm@0 109 ALenum channels, ALenum type, ALvoid *data);
rlm@0 110 AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format);
rlm@0 111 #endif
rlm@0 112 #endif
rlm@0 113
rlm@0 114 #ifndef AL_SOFT_non_virtual_channels
rlm@0 115 #define AL_SOFT_non_virtual_channels 1
rlm@0 116 #define AL_VIRTUAL_CHANNELS_SOFT 0x1033
rlm@0 117 #endif
rlm@0 118
rlm@0 119 #ifndef AL_SOFT_deferred_updates
rlm@0 120 #define AL_SOFT_deferred_updates 1
rlm@0 121 #define AL_DEFERRED_UPDATES_SOFT 0xC002
rlm@0 122 typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void);
rlm@0 123 typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void);
rlm@0 124 #ifdef AL_ALEXT_PROTOTYPES
rlm@0 125 AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void);
rlm@0 126 AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void);
rlm@0 127 #endif
rlm@0 128 #endif
rlm@0 129
rlm@0 130
rlm@0 131 #if defined(HAVE_STDINT_H)
rlm@0 132 #include <stdint.h>
rlm@0 133 typedef int64_t ALint64;
rlm@0 134 typedef uint64_t ALuint64;
rlm@0 135 #elif defined(HAVE___INT64)
rlm@0 136 typedef __int64 ALint64;
rlm@0 137 typedef unsigned __int64 ALuint64;
rlm@0 138 #elif (SIZEOF_LONG == 8)
rlm@0 139 typedef long ALint64;
rlm@0 140 typedef unsigned long ALuint64;
rlm@0 141 #elif (SIZEOF_LONG_LONG == 8)
rlm@0 142 typedef long long ALint64;
rlm@0 143 typedef unsigned long long ALuint64;
rlm@0 144 #endif
rlm@0 145
rlm@0 146 typedef ptrdiff_t ALintptrEXT;
rlm@0 147 typedef ptrdiff_t ALsizeiptrEXT;
rlm@0 148
rlm@0 149 #ifdef HAVE_GCC_FORMAT
rlm@0 150 #define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
rlm@0 151 #else
rlm@0 152 #define PRINTF_STYLE(x, y)
rlm@0 153 #endif
rlm@0 154
rlm@0 155 #if defined(HAVE_RESTRICT)
rlm@0 156 #define RESTRICT restrict
rlm@0 157 #elif defined(HAVE___RESTRICT)
rlm@0 158 #define RESTRICT __restrict
rlm@0 159 #else
rlm@0 160 #define RESTRICT
rlm@0 161 #endif
rlm@0 162
rlm@0 163 #ifdef _WIN32
rlm@0 164
rlm@0 165 #ifndef _WIN32_WINNT
rlm@0 166 #define _WIN32_WINNT 0x0500
rlm@0 167 #endif
rlm@0 168 #include <windows.h>
rlm@0 169
rlm@0 170 typedef DWORD tls_type;
rlm@0 171 #define tls_create(x) (*(x) = TlsAlloc())
rlm@0 172 #define tls_delete(x) TlsFree((x))
rlm@0 173 #define tls_get(x) TlsGetValue((x))
rlm@0 174 #define tls_set(x, a) TlsSetValue((x), (a))
rlm@0 175
rlm@0 176 #define HAVE_DYNLOAD 1
rlm@0 177 void *LoadLib(const char *name);
rlm@0 178 void CloseLib(void *handle);
rlm@0 179 void *GetSymbol(void *handle, const char *name);
rlm@0 180
rlm@0 181 typedef LONG pthread_once_t;
rlm@0 182 #define PTHREAD_ONCE_INIT 0
rlm@0 183 void pthread_once(pthread_once_t *once, void (*callback)(void));
rlm@0 184
rlm@0 185 #else
rlm@0 186
rlm@0 187 #include <unistd.h>
rlm@0 188 #include <assert.h>
rlm@0 189 #include <pthread.h>
rlm@0 190 #ifdef HAVE_PTHREAD_NP_H
rlm@0 191 #include <pthread_np.h>
rlm@0 192 #endif
rlm@0 193 #include <sys/time.h>
rlm@0 194 #include <time.h>
rlm@0 195 #include <errno.h>
rlm@0 196
rlm@0 197 #define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0)
rlm@0 198
rlm@0 199 typedef pthread_key_t tls_type;
rlm@0 200 #define tls_create(x) pthread_key_create((x), NULL)
rlm@0 201 #define tls_delete(x) pthread_key_delete((x))
rlm@0 202 #define tls_get(x) pthread_getspecific((x))
rlm@0 203 #define tls_set(x, a) pthread_setspecific((x), (a))
rlm@0 204
rlm@0 205 typedef pthread_mutex_t CRITICAL_SECTION;
rlm@0 206 void InitializeCriticalSection(CRITICAL_SECTION *cs);
rlm@0 207 void DeleteCriticalSection(CRITICAL_SECTION *cs);
rlm@0 208 void EnterCriticalSection(CRITICAL_SECTION *cs);
rlm@0 209 void LeaveCriticalSection(CRITICAL_SECTION *cs);
rlm@0 210
rlm@0 211 ALuint timeGetTime(void);
rlm@0 212
rlm@0 213 static __inline void Sleep(ALuint t)
rlm@0 214 {
rlm@0 215 struct timespec tv, rem;
rlm@0 216 tv.tv_nsec = (t*1000000)%1000000000;
rlm@0 217 tv.tv_sec = t/1000;
rlm@0 218
rlm@0 219 while(nanosleep(&tv, &rem) == -1 && errno == EINTR)
rlm@0 220 tv = rem;
rlm@0 221 }
rlm@0 222
rlm@0 223 #if defined(HAVE_DLFCN_H)
rlm@0 224 #define HAVE_DYNLOAD 1
rlm@0 225 void *LoadLib(const char *name);
rlm@0 226 void CloseLib(void *handle);
rlm@0 227 void *GetSymbol(void *handle, const char *name);
rlm@0 228 #endif
rlm@0 229
rlm@0 230 #endif
rlm@0 231
rlm@0 232 #include "alListener.h"
rlm@0 233 #include "alu.h"
rlm@0 234
rlm@0 235 #ifdef __cplusplus
rlm@0 236 extern "C" {
rlm@0 237 #endif
rlm@0 238
rlm@0 239
rlm@0 240 #define DEFAULT_OUTPUT_RATE (44100)
rlm@0 241
rlm@0 242 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
rlm@0 243 #define AIRABSORBGAINHF (0.99426) /* -0.05dB */
rlm@0 244
rlm@0 245 #define LOWPASSFREQCUTOFF (5000)
rlm@0 246
rlm@0 247
rlm@0 248 // Find the next power-of-2 for non-power-of-2 numbers.
rlm@0 249 static __inline ALuint NextPowerOf2(ALuint value)
rlm@0 250 {
rlm@0 251 ALuint powerOf2 = 1;
rlm@0 252
rlm@0 253 if(value)
rlm@0 254 {
rlm@0 255 value--;
rlm@0 256 while(value)
rlm@0 257 {
rlm@0 258 value >>= 1;
rlm@0 259 powerOf2 <<= 1;
rlm@0 260 }
rlm@0 261 }
rlm@0 262 return powerOf2;
rlm@0 263 }
rlm@0 264
rlm@0 265
rlm@0 266 enum DevProbe {
rlm@0 267 DEVICE_PROBE,
rlm@0 268 ALL_DEVICE_PROBE,
rlm@0 269 CAPTURE_DEVICE_PROBE
rlm@0 270 };
rlm@0 271
rlm@0 272 typedef struct {
rlm@0 273 ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*);
rlm@0 274 void (*ClosePlayback)(ALCdevice*);
rlm@0 275 ALCboolean (*ResetPlayback)(ALCdevice*);
rlm@0 276 void (*StopPlayback)(ALCdevice*);
rlm@0 277
rlm@0 278 ALCboolean (*OpenCapture)(ALCdevice*, const ALCchar*);
rlm@0 279 void (*CloseCapture)(ALCdevice*);
rlm@0 280 void (*StartCapture)(ALCdevice*);
rlm@0 281 void (*StopCapture)(ALCdevice*);
rlm@0 282 void (*CaptureSamples)(ALCdevice*, void*, ALCuint);
rlm@0 283 ALCuint (*AvailableSamples)(ALCdevice*);
rlm@0 284 } BackendFuncs;
rlm@0 285
rlm@0 286 struct BackendInfo {
rlm@0 287 const char *name;
rlm@0 288 ALCboolean (*Init)(BackendFuncs*);
rlm@0 289 void (*Deinit)(void);
rlm@0 290 void (*Probe)(enum DevProbe);
rlm@0 291 BackendFuncs Funcs;
rlm@0 292 };
rlm@0 293
rlm@3 294
rlm@0 295 ALCboolean alc_null_init(BackendFuncs *func_list);
rlm@0 296 void alc_null_deinit(void);
rlm@0 297 void alc_null_probe(enum DevProbe type);
rlm@0 298 ALCboolean alc_loopback_init(BackendFuncs *func_list);
rlm@0 299 void alc_loopback_deinit(void);
rlm@0 300 void alc_loopback_probe(enum DevProbe type);
rlm@0 301
rlm@0 302 //RLM: aurellem send device insertion
rlm@0 303 ALCboolean alc_send_init(BackendFuncs *func_list);
rlm@0 304 void alc_send_deinit(void);
rlm@0 305 void alc_send_probe(enum DevProbe type);
rlm@0 306
rlm@0 307
rlm@0 308 typedef struct UIntMap {
rlm@0 309 struct {
rlm@0 310 ALuint key;
rlm@0 311 ALvoid *value;
rlm@0 312 } *array;
rlm@0 313 ALsizei size;
rlm@0 314 ALsizei maxsize;
rlm@0 315 } UIntMap;
rlm@0 316
rlm@0 317 void InitUIntMap(UIntMap *map);
rlm@0 318 void ResetUIntMap(UIntMap *map);
rlm@0 319 ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
rlm@0 320 void RemoveUIntMapKey(UIntMap *map, ALuint key);
rlm@0 321 ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
rlm@0 322
rlm@0 323 /* Device formats */
rlm@0 324 enum DevFmtType {
rlm@0 325 DevFmtByte = AL_BYTE,
rlm@0 326 DevFmtUByte = AL_UNSIGNED_BYTE,
rlm@0 327 DevFmtShort = AL_SHORT,
rlm@0 328 DevFmtUShort = AL_UNSIGNED_SHORT,
rlm@0 329 DevFmtFloat = AL_FLOAT
rlm@0 330 };
rlm@0 331 enum DevFmtChannels {
rlm@0 332 DevFmtMono = AL_MONO,
rlm@0 333 DevFmtStereo = AL_STEREO,
rlm@0 334 DevFmtQuad = AL_QUAD,
rlm@0 335 DevFmtX51 = AL_5POINT1,
rlm@0 336 DevFmtX61 = AL_6POINT1,
rlm@0 337 DevFmtX71 = AL_7POINT1,
rlm@0 338
rlm@0 339 /* Similar to 5.1, except using the side channels instead of back */
rlm@0 340 DevFmtX51Side = 0x80000000 | AL_5POINT1
rlm@0 341 };
rlm@0 342
rlm@0 343 ALuint BytesFromDevFmt(enum DevFmtType type);
rlm@0 344 ALuint ChannelsFromDevFmt(enum DevFmtChannels chans);
rlm@0 345 static __inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans,
rlm@0 346 enum DevFmtType type)
rlm@0 347 {
rlm@0 348 return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type);
rlm@0 349 }
rlm@0 350
rlm@0 351
rlm@0 352 extern const struct EffectList {
rlm@0 353 const char *name;
rlm@0 354 int type;
rlm@0 355 const char *ename;
rlm@0 356 ALenum val;
rlm@0 357 } EffectList[];
rlm@0 358
rlm@0 359
rlm@0 360 struct ALCdevice_struct
rlm@0 361 {
rlm@0 362 ALCboolean Connected;
rlm@0 363 ALboolean IsCaptureDevice;
rlm@0 364 ALboolean IsLoopbackDevice;
rlm@0 365
rlm@0 366 CRITICAL_SECTION Mutex;
rlm@0 367
rlm@0 368 ALuint Frequency;
rlm@0 369 ALuint UpdateSize;
rlm@0 370 ALuint NumUpdates;
rlm@0 371 enum DevFmtChannels FmtChans;
rlm@0 372 enum DevFmtType FmtType;
rlm@0 373
rlm@0 374 ALCchar *szDeviceName;
rlm@0 375
rlm@0 376 ALCenum LastError;
rlm@0 377
rlm@0 378 // Maximum number of sources that can be created
rlm@0 379 ALuint MaxNoOfSources;
rlm@0 380 // Maximum number of slots that can be created
rlm@0 381 ALuint AuxiliaryEffectSlotMax;
rlm@0 382
rlm@0 383 ALCuint NumMonoSources;
rlm@0 384 ALCuint NumStereoSources;
rlm@0 385 ALuint NumAuxSends;
rlm@0 386
rlm@0 387 // Map of Buffers for this device
rlm@0 388 UIntMap BufferMap;
rlm@0 389
rlm@0 390 // Map of Effects for this device
rlm@0 391 UIntMap EffectMap;
rlm@0 392
rlm@0 393 // Map of Filters for this device
rlm@0 394 UIntMap FilterMap;
rlm@0 395
rlm@0 396 // Stereo-to-binaural filter
rlm@0 397 struct bs2b *Bs2b;
rlm@0 398 ALCint Bs2bLevel;
rlm@0 399
rlm@0 400 // Device flags
rlm@0 401 ALuint Flags;
rlm@0 402
rlm@0 403 // Dry path buffer mix
rlm@0 404 ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS];
rlm@0 405
rlm@0 406 enum Channel DevChannels[MAXCHANNELS];
rlm@0 407
rlm@0 408 enum Channel Speaker2Chan[MAXCHANNELS];
rlm@0 409 ALfloat PanningLUT[LUT_NUM][MAXCHANNELS];
rlm@0 410 ALuint NumChan;
rlm@0 411
rlm@0 412 ALfloat ClickRemoval[MAXCHANNELS];
rlm@0 413 ALfloat PendingClicks[MAXCHANNELS];
rlm@0 414
rlm@0 415 // Contexts created on this device
rlm@0 416 ALCcontext **Contexts;
rlm@0 417 ALuint NumContexts;
rlm@0 418
rlm@0 419 BackendFuncs *Funcs;
rlm@0 420 void *ExtraData; // For the backend's use
rlm@0 421
rlm@0 422 ALCdevice *next;
rlm@0 423 };
rlm@0 424
rlm@0 425 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
rlm@0 426 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
rlm@0 427 #define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
rlm@0 428 #define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
rlm@0 429 #define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
rlm@0 430 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
rlm@0 431 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
rlm@0 432 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
rlm@0 433 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
rlm@0 434 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
rlm@0 435
rlm@0 436 // Duplicate stereo sources on the side/rear channels
rlm@0 437 #define DEVICE_DUPLICATE_STEREO (1<<0)
rlm@0 438 // Use HRTF filters for mixing sounds
rlm@0 439 #define DEVICE_USE_HRTF (1<<1)
rlm@0 440 // Frequency was requested by the app or config file
rlm@0 441 #define DEVICE_FREQUENCY_REQUEST (1<<2)
rlm@0 442 // Channel configuration was requested by the config file
rlm@0 443 #define DEVICE_CHANNELS_REQUEST (1<<3)
rlm@0 444
rlm@0 445 // Specifies if the device is currently running
rlm@0 446 #define DEVICE_RUNNING (1<<31)
rlm@0 447
rlm@0 448 struct ALCcontext_struct
rlm@0 449 {
rlm@0 450 ALlistener Listener;
rlm@0 451
rlm@0 452 UIntMap SourceMap;
rlm@0 453 UIntMap EffectSlotMap;
rlm@0 454
rlm@0 455 ALenum LastError;
rlm@0 456
rlm@0 457 ALboolean UpdateSources;
rlm@0 458
rlm@0 459 enum DistanceModel DistanceModel;
rlm@0 460 ALboolean SourceDistanceModel;
rlm@0 461
rlm@0 462 ALfloat DopplerFactor;
rlm@0 463 ALfloat DopplerVelocity;
rlm@0 464 ALfloat flSpeedOfSound;
rlm@0 465 ALboolean DeferUpdates;
rlm@0 466
rlm@0 467 struct ALsource **ActiveSources;
rlm@0 468 ALsizei ActiveSourceCount;
rlm@0 469 ALsizei MaxActiveSources;
rlm@0 470
rlm@0 471 ALCdevice *Device;
rlm@0 472 const ALCchar *ExtensionList;
rlm@0 473
rlm@0 474 ALCcontext *next;
rlm@0 475 };
rlm@0 476
rlm@0 477 void AppendDeviceList(const ALCchar *name);
rlm@0 478 void AppendAllDeviceList(const ALCchar *name);
rlm@0 479 void AppendCaptureDeviceList(const ALCchar *name);
rlm@0 480
rlm@0 481 ALCvoid alcSetError(ALCdevice *device, ALenum errorCode);
rlm@0 482
rlm@0 483 ALCvoid LockDevice(ALCdevice *device);
rlm@0 484 ALCvoid UnlockDevice(ALCdevice *device);
rlm@0 485 ALCvoid LockContext(ALCcontext *context);
rlm@0 486 ALCvoid UnlockContext(ALCcontext *context);
rlm@0 487
rlm@0 488 ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
rlm@0 489 ALuint StopThread(ALvoid *thread);
rlm@0 490
rlm@0 491 ALCcontext *GetLockedContext(void);
rlm@0 492
rlm@0 493 typedef struct RingBuffer RingBuffer;
rlm@0 494 RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
rlm@0 495 void DestroyRingBuffer(RingBuffer *ring);
rlm@0 496 ALsizei RingBufferSize(RingBuffer *ring);
rlm@0 497 void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
rlm@0 498 void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
rlm@0 499
rlm@0 500 void ReadALConfig(void);
rlm@0 501 void FreeALConfig(void);
rlm@0 502 int ConfigValueExists(const char *blockName, const char *keyName);
rlm@0 503 const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
rlm@0 504 int GetConfigValueInt(const char *blockName, const char *keyName, int def);
rlm@0 505 float GetConfigValueFloat(const char *blockName, const char *keyName, float def);
rlm@0 506 int GetConfigValueBool(const char *blockName, const char *keyName, int def);
rlm@0 507
rlm@0 508 void SetRTPriority(void);
rlm@0 509
rlm@0 510 void SetDefaultChannelOrder(ALCdevice *device);
rlm@0 511 void SetDefaultWFXChannelOrder(ALCdevice *device);
rlm@0 512
rlm@0 513 const ALCchar *DevFmtTypeString(enum DevFmtType type);
rlm@0 514 const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans);
rlm@0 515
rlm@0 516 #define HRIR_BITS (5)
rlm@0 517 #define HRIR_LENGTH (1<<HRIR_BITS)
rlm@0 518 #define HRIR_MASK (HRIR_LENGTH-1)
rlm@0 519 void InitHrtf(void);
rlm@0 520 ALCboolean IsHrtfCompatible(ALCdevice *device);
rlm@0 521 ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]);
rlm@0 522 void GetLerpedHrtfCoeffs(ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays);
rlm@0 523 ALuint GetMovingHrtfCoeffs(ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat delta, ALint counter, ALfloat (*coeffs)[2], ALuint *delays, ALfloat (*coeffStep)[2], ALint *delayStep);
rlm@0 524
rlm@0 525 void al_print(const char *fname, unsigned int line, const char *fmt, ...)
rlm@0 526 PRINTF_STYLE(3,4);
rlm@0 527 #define AL_PRINT(...) al_print(__FILE__, __LINE__, __VA_ARGS__)
rlm@0 528
rlm@0 529 extern FILE *LogFile;
rlm@0 530 enum LogLevel {
rlm@0 531 NoLog,
rlm@0 532 LogError,
rlm@0 533 LogWarning,
rlm@0 534 LogTrace
rlm@0 535 };
rlm@0 536 extern enum LogLevel LogLevel;
rlm@0 537
rlm@0 538 #define TRACE(...) do { \
rlm@0 539 if(LogLevel >= LogTrace) \
rlm@0 540 AL_PRINT(__VA_ARGS__); \
rlm@0 541 } while(0)
rlm@0 542
rlm@0 543 #define WARN(...) do { \
rlm@0 544 if(LogLevel >= LogWarning) \
rlm@0 545 AL_PRINT(__VA_ARGS__); \
rlm@0 546 } while(0)
rlm@0 547
rlm@0 548 #define ERR(...) do { \
rlm@0 549 if(LogLevel >= LogError) \
rlm@0 550 AL_PRINT(__VA_ARGS__); \
rlm@0 551 } while(0)
rlm@0 552
rlm@0 553
rlm@0 554 extern ALdouble ConeScale;
rlm@0 555 extern ALdouble ZScale;
rlm@0 556
rlm@0 557 extern ALint RTPrioLevel;
rlm@0 558
rlm@0 559 #ifdef __cplusplus
rlm@0 560 }
rlm@0 561 #endif
rlm@0 562
rlm@0 563 #endif