Make alIsSoundfontSOFT check soundfont IDs
[openal-soft.git] / OpenAL32 / Include / alMain.h
blobda7171684978693fcbe2b98f82e17e5e6b2afd50
1 #ifndef AL_MAIN_H
2 #define AL_MAIN_H
4 #include <string.h>
5 #include <stdio.h>
6 #include <stdarg.h>
7 #include <assert.h>
8 #include <math.h>
10 #ifdef HAVE_STRINGS_H
11 #include <strings.h>
12 #endif
14 #ifdef HAVE_FENV_H
15 #include <fenv.h>
16 #endif
18 #include "AL/al.h"
19 #include "AL/alc.h"
20 #include "AL/alext.h"
22 #include "atomic.h"
23 #include "uintmap.h"
25 #ifndef ALC_SOFT_HRTF
26 #define ALC_SOFT_HRTF 1
27 #define ALC_HRTF_SOFT 0x1992
28 #endif
30 #ifndef ALC_SOFT_midi_interface
31 #define ALC_SOFT_midi_interface 1
32 #define AL_MIDI_CLOCK_SOFT 0x9999
33 #define AL_MIDI_GAIN_SOFT 0x9998
34 #define AL_NOTEOFF_SOFT 0x0080
35 #define AL_NOTEON_SOFT 0x0090
36 #define AL_AFTERTOUCH_SOFT 0x00A0
37 #define AL_CONTROLLERCHANGE_SOFT 0x00B0
38 #define AL_PROGRAMCHANGE_SOFT 0x00C0
39 #define AL_CHANNELPRESSURE_SOFT 0x00D0
40 #define AL_PITCHBEND_SOFT 0x00E0
41 typedef void (AL_APIENTRY*LPALGENSOUNDFONTSSOFT)(ALsizei n, ALuint *ids);
42 typedef void (AL_APIENTRY*LPALDELETESOUNDFONTSSOFT)(ALsizei n, const ALuint *ids);
43 typedef ALboolean (AL_APIENTRY*LPALISSOUNDFONTSOFT)(ALuint id);
44 typedef void (AL_APIENTRY*LPALMIDISOUNDFONTSOFT)(const char *filename);
45 typedef void (AL_APIENTRY*LPALMIDIEVENTSOFT)(ALuint64SOFT time, ALenum event, ALsizei channel, ALsizei param1, ALsizei param2);
46 typedef void (AL_APIENTRY*LPALMIDISYSEXSOFT)(ALuint64SOFT time, const ALbyte *data, ALsizei size);
47 typedef void (AL_APIENTRY*LPALMIDIPLAYSOFT)(void);
48 typedef void (AL_APIENTRY*LPALMIDIPAUSESOFT)(void);
49 typedef void (AL_APIENTRY*LPALMIDISTOPSOFT)(void);
50 typedef void (AL_APIENTRY*LPALMIDIRESETSOFT)(void);
51 typedef void (AL_APIENTRY*LPALMIDIGAINSOFT)(ALfloat value);
52 typedef ALint64SOFT (AL_APIENTRY*LPALGETINTEGER64SOFT)(ALenum pname);
53 typedef void (AL_APIENTRY*LPALGETINTEGER64VSOFT)(ALenum pname, ALint64SOFT *values);
54 #ifdef AL_ALEXT_PROTOTYPES
55 AL_API void AL_APIENTRY alGenSoundfontsSOFT(ALsizei n, ALuint *ids);
56 AL_API void AL_APIENTRY alDeleteSoundfontsSOFT(ALsizei n, const ALuint *ids);
57 AL_API ALboolean AL_APIENTRY alIsSoundfontSOFT(ALuint id);
58 AL_API void AL_APIENTRY alMidiSoundfontSOFT(const char *filename);
59 AL_API void AL_APIENTRY alMidiEventSOFT(ALuint64SOFT time, ALenum event, ALsizei channel, ALsizei param1, ALsizei param2);
60 AL_API void AL_APIENTRY alMidiSysExSOFT(ALuint64SOFT time, const ALbyte *data, ALsizei size);
61 AL_API void AL_APIENTRY alMidiPlaySOFT(void);
62 AL_API void AL_APIENTRY alMidiPauseSOFT(void);
63 AL_API void AL_APIENTRY alMidiStopSOFT(void);
64 AL_API void AL_APIENTRY alMidiResetSOFT(void);
65 AL_API void AL_APIENTRY alMidiGainSOFT(ALfloat value);
66 AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname);
67 AL_API void AL_APIENTRY alGetInteger64vSOFT(ALenum pname, ALint64SOFT *values);
68 #endif
69 #endif
72 #ifdef IN_IDE_PARSER
73 /* KDevelop's parser doesn't recognize the C99-standard restrict keyword, but
74 * recent versions (at least 4.5.1) do recognize GCC's __restrict. */
75 #define restrict __restrict
76 /* KDevelop won't see the ALIGN macro from config.h when viewing files that
77 * don't include it directly (e.g. headers). */
78 #ifndef ALIGN
79 #define ALIGN(x)
80 #endif
81 #endif
84 typedef ALint64SOFT ALint64;
85 typedef ALuint64SOFT ALuint64;
87 typedef ptrdiff_t ALintptrEXT;
88 typedef ptrdiff_t ALsizeiptrEXT;
90 #ifndef U64
91 #if defined(_MSC_VER)
92 #define U64(x) ((ALuint64)(x##ui64))
93 #elif SIZEOF_LONG == 8
94 #define U64(x) ((ALuint64)(x##ul))
95 #elif SIZEOF_LONG_LONG == 8
96 #define U64(x) ((ALuint64)(x##ull))
97 #endif
98 #endif
100 #ifndef UINT64_MAX
101 #define UINT64_MAX U64(18446744073709551615)
102 #endif
104 #ifndef UNUSED
105 #if defined(__cplusplus)
106 #define UNUSED(x)
107 #elif defined(__GNUC__)
108 #define UNUSED(x) UNUSED_##x __attribute__((unused))
109 #elif defined(__LCLINT__)
110 #define UNUSED(x) /*@unused@*/ x
111 #else
112 #define UNUSED(x) x
113 #endif
114 #endif
116 #ifdef HAVE_GCC_FORMAT
117 #define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
118 #else
119 #define PRINTF_STYLE(x, y)
120 #endif
122 #if defined(__GNUC__) && defined(__i386__)
123 /* force_align_arg_pointer is required for proper function arguments aligning
124 * when SSE code is used. Some systems (Windows, QNX) do not guarantee our
125 * thread functions will be properly aligned on the stack, even though GCC may
126 * generate code with the assumption that it is. */
127 #define FORCE_ALIGN __attribute__((force_align_arg_pointer))
128 #else
129 #define FORCE_ALIGN
130 #endif
133 static const union {
134 ALuint u;
135 ALubyte b[sizeof(ALuint)];
136 } EndianTest = { 1 };
137 #define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
139 #define COUNTOF(x) (sizeof((x))/sizeof((x)[0]))
142 #define DERIVE_FROM_TYPE(t) t t##_parent
143 #define STATIC_CAST(to, obj) (&(obj)->to##_parent)
144 #define STATIC_UPCAST(to, from, obj) ((to*)((char*)(obj) - offsetof(to, from##_parent)))
147 #define DECLARE_FORWARD(T1, T2, rettype, func) \
148 rettype T1##_##func(T1 *obj) \
149 { return T2##_##func(STATIC_CAST(T2, obj)); }
151 #define DECLARE_FORWARD1(T1, T2, rettype, func, argtype1) \
152 rettype T1##_##func(T1 *obj, argtype1 a) \
153 { return T2##_##func(STATIC_CAST(T2, obj), a); }
155 #define DECLARE_FORWARD2(T1, T2, rettype, func, argtype1, argtype2) \
156 rettype T1##_##func(T1 *obj, argtype1 a, argtype2 b) \
157 { return T2##_##func(STATIC_CAST(T2, obj), a, b); }
160 #define GET_VTABLE1(T1) (&(T1##_vtable))
161 #define GET_VTABLE2(T1, T2) (&(T1##_##T2##_vtable))
163 #define SET_VTABLE1(T1, obj) ((obj)->vtbl = GET_VTABLE1(T1))
164 #define SET_VTABLE2(T1, T2, obj) (STATIC_CAST(T2, obj)->vtbl = GET_VTABLE2(T1, T2))
166 #define DECLARE_THUNK(T1, T2, rettype, func) \
167 static rettype T1##_##T2##_##func(T2 *obj) \
168 { return T1##_##func(STATIC_UPCAST(T1, T2, obj)); }
170 #define DECLARE_THUNK1(T1, T2, rettype, func, argtype1) \
171 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a) \
172 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a); }
174 #define DECLARE_THUNK2(T1, T2, rettype, func, argtype1, argtype2) \
175 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b) \
176 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b); }
178 #define DECLARE_THUNK3(T1, T2, rettype, func, argtype1, argtype2, argtype3) \
179 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b, argtype3 c) \
180 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b, c); }
183 /* Helper to extract an argument list for VCALL. Not used directly. */
184 #define EXTRACT_VCALL_ARGS(...) __VA_ARGS__))
186 /* Call a "virtual" method on an object, with arguments. */
187 #define V(obj, func) ((obj)->vtbl->func((obj), EXTRACT_VCALL_ARGS
188 /* Call a "virtual" method on an object, with no arguments. */
189 #define V0(obj, func) ((obj)->vtbl->func((obj) EXTRACT_VCALL_ARGS
191 #define DELETE_OBJ(obj) do { \
192 if((obj) != NULL) \
194 V0((obj),Destruct)(); \
195 V0((obj),Delete)(); \
197 } while(0)
200 #ifdef __cplusplus
201 extern "C" {
202 #endif
204 struct Hrtf;
207 #define DEFAULT_OUTPUT_RATE (44100)
208 #define MIN_OUTPUT_RATE (8000)
211 /* Find the next power-of-2 for non-power-of-2 numbers. */
212 inline ALuint NextPowerOf2(ALuint value)
214 if(value > 0)
216 value--;
217 value |= value>>1;
218 value |= value>>2;
219 value |= value>>4;
220 value |= value>>8;
221 value |= value>>16;
223 return value+1;
226 /* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
227 * mode. */
228 inline ALint fastf2i(ALfloat f)
230 #ifdef HAVE_LRINTF
231 return lrintf(f);
232 #elif defined(_MSC_VER) && defined(_M_IX86)
233 ALint i;
234 __asm fld f
235 __asm fistp i
236 return i;
237 #else
238 return (ALint)f;
239 #endif
242 /* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
243 * mode. */
244 inline ALuint fastf2u(ALfloat f)
245 { return fastf2i(f); }
248 enum DevProbe {
249 ALL_DEVICE_PROBE,
250 CAPTURE_DEVICE_PROBE
253 typedef struct {
254 ALCenum (*OpenPlayback)(ALCdevice*, const ALCchar*);
255 void (*ClosePlayback)(ALCdevice*);
256 ALCboolean (*ResetPlayback)(ALCdevice*);
257 ALCboolean (*StartPlayback)(ALCdevice*);
258 void (*StopPlayback)(ALCdevice*);
260 ALCenum (*OpenCapture)(ALCdevice*, const ALCchar*);
261 void (*CloseCapture)(ALCdevice*);
262 void (*StartCapture)(ALCdevice*);
263 void (*StopCapture)(ALCdevice*);
264 ALCenum (*CaptureSamples)(ALCdevice*, void*, ALCuint);
265 ALCuint (*AvailableSamples)(ALCdevice*);
267 ALint64 (*GetLatency)(ALCdevice*);
268 } BackendFuncs;
270 ALCboolean alc_solaris_init(BackendFuncs *func_list);
271 void alc_solaris_deinit(void);
272 void alc_solaris_probe(enum DevProbe type);
273 ALCboolean alc_sndio_init(BackendFuncs *func_list);
274 void alc_sndio_deinit(void);
275 void alc_sndio_probe(enum DevProbe type);
276 ALCboolean alcMMDevApiInit(BackendFuncs *func_list);
277 void alcMMDevApiDeinit(void);
278 void alcMMDevApiProbe(enum DevProbe type);
279 ALCboolean alcDSoundInit(BackendFuncs *func_list);
280 void alcDSoundDeinit(void);
281 void alcDSoundProbe(enum DevProbe type);
282 ALCboolean alcWinMMInit(BackendFuncs *FuncList);
283 void alcWinMMDeinit(void);
284 void alcWinMMProbe(enum DevProbe type);
285 ALCboolean alc_pa_init(BackendFuncs *func_list);
286 void alc_pa_deinit(void);
287 void alc_pa_probe(enum DevProbe type);
288 ALCboolean alc_wave_init(BackendFuncs *func_list);
289 void alc_wave_deinit(void);
290 void alc_wave_probe(enum DevProbe type);
291 ALCboolean alc_ca_init(BackendFuncs *func_list);
292 void alc_ca_deinit(void);
293 void alc_ca_probe(enum DevProbe type);
294 ALCboolean alc_opensl_init(BackendFuncs *func_list);
295 void alc_opensl_deinit(void);
296 void alc_opensl_probe(enum DevProbe type);
297 ALCboolean alc_qsa_init(BackendFuncs *func_list);
298 void alc_qsa_deinit(void);
299 void alc_qsa_probe(enum DevProbe type);
301 struct ALCbackend;
304 enum DistanceModel {
305 InverseDistanceClamped = AL_INVERSE_DISTANCE_CLAMPED,
306 LinearDistanceClamped = AL_LINEAR_DISTANCE_CLAMPED,
307 ExponentDistanceClamped = AL_EXPONENT_DISTANCE_CLAMPED,
308 InverseDistance = AL_INVERSE_DISTANCE,
309 LinearDistance = AL_LINEAR_DISTANCE,
310 ExponentDistance = AL_EXPONENT_DISTANCE,
311 DisableDistance = AL_NONE,
313 DefaultDistanceModel = InverseDistanceClamped
316 enum Resampler {
317 PointResampler,
318 LinearResampler,
319 CubicResampler,
321 ResamplerMax,
324 enum Channel {
325 FrontLeft = 0,
326 FrontRight,
327 FrontCenter,
328 LFE,
329 BackLeft,
330 BackRight,
331 BackCenter,
332 SideLeft,
333 SideRight,
335 MaxChannels,
339 /* Device formats */
340 enum DevFmtType {
341 DevFmtByte = ALC_BYTE_SOFT,
342 DevFmtUByte = ALC_UNSIGNED_BYTE_SOFT,
343 DevFmtShort = ALC_SHORT_SOFT,
344 DevFmtUShort = ALC_UNSIGNED_SHORT_SOFT,
345 DevFmtInt = ALC_INT_SOFT,
346 DevFmtUInt = ALC_UNSIGNED_INT_SOFT,
347 DevFmtFloat = ALC_FLOAT_SOFT,
349 DevFmtTypeDefault = DevFmtFloat
351 enum DevFmtChannels {
352 DevFmtMono = ALC_MONO_SOFT,
353 DevFmtStereo = ALC_STEREO_SOFT,
354 DevFmtQuad = ALC_QUAD_SOFT,
355 DevFmtX51 = ALC_5POINT1_SOFT,
356 DevFmtX61 = ALC_6POINT1_SOFT,
357 DevFmtX71 = ALC_7POINT1_SOFT,
359 /* Similar to 5.1, except using the side channels instead of back */
360 DevFmtX51Side = 0x80000000,
362 DevFmtChannelsDefault = DevFmtStereo
365 ALuint BytesFromDevFmt(enum DevFmtType type);
366 ALuint ChannelsFromDevFmt(enum DevFmtChannels chans);
367 inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans, enum DevFmtType type)
369 return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type);
373 extern const struct EffectList {
374 const char *name;
375 int type;
376 const char *ename;
377 ALenum val;
378 } EffectList[];
381 enum DeviceType {
382 Playback,
383 Capture,
384 Loopback
388 /* Size for temporary storage of buffer data, in ALfloats. Larger values need
389 * more memory, while smaller values may need more iterations. The value needs
390 * to be a sensible size, however, as it constrains the max stepping value used
391 * for mixing, as well as the maximum number of samples per mixing iteration.
393 #define BUFFERSIZE (2048u)
396 struct ALCdevice_struct
398 volatile RefCount ref;
400 ALCboolean Connected;
401 enum DeviceType Type;
403 ALuint Frequency;
404 ALuint UpdateSize;
405 ALuint NumUpdates;
406 enum DevFmtChannels FmtChans;
407 enum DevFmtType FmtType;
409 ALCchar *DeviceName;
411 volatile ALCenum LastError;
413 // Maximum number of sources that can be created
414 ALuint MaxNoOfSources;
415 // Maximum number of slots that can be created
416 ALuint AuxiliaryEffectSlotMax;
418 ALCuint NumMonoSources;
419 ALCuint NumStereoSources;
420 ALuint NumAuxSends;
422 // Map of Buffers for this device
423 UIntMap BufferMap;
425 // Map of Effects for this device
426 UIntMap EffectMap;
428 // Map of Filters for this device
429 UIntMap FilterMap;
431 // Map of Soundfonts for this device
432 UIntMap SfontMap;
434 /* MIDI synth engine */
435 struct MidiSynth *Synth;
437 /* HRTF filter tables */
438 const struct Hrtf *Hrtf;
440 // Stereo-to-binaural filter
441 struct bs2b *Bs2b;
442 ALCint Bs2bLevel;
444 // Device flags
445 ALuint Flags;
447 ALuint ChannelOffsets[MaxChannels];
449 enum Channel Speaker2Chan[MaxChannels];
450 ALfloat SpeakerAngle[MaxChannels];
451 ALuint NumChan;
453 /* Temp storage used for mixing. +1 for the predictive sample. */
454 ALIGN(16) ALfloat SampleData1[BUFFERSIZE+1];
455 ALIGN(16) ALfloat SampleData2[BUFFERSIZE+1];
457 // Dry path buffer mix
458 ALIGN(16) ALfloat DryBuffer[MaxChannels][BUFFERSIZE];
460 ALIGN(16) ALfloat ClickRemoval[MaxChannels];
461 ALIGN(16) ALfloat PendingClicks[MaxChannels];
463 /* Default effect slot */
464 struct ALeffectslot *DefaultSlot;
466 // Contexts created on this device
467 ALCcontext *volatile ContextList;
469 struct ALCbackend *Backend;
471 BackendFuncs *Funcs;
472 void *ExtraData; // For the backend's use
474 ALCdevice *volatile next;
477 // Frequency was requested by the app or config file
478 #define DEVICE_FREQUENCY_REQUEST (1<<1)
479 // Channel configuration was requested by the config file
480 #define DEVICE_CHANNELS_REQUEST (1<<2)
481 // Sample type was requested by the config file
482 #define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
483 // HRTF was requested by the app
484 #define DEVICE_HRTF_REQUEST (1<<4)
486 // Stereo sources cover 120-degree angles around +/-90
487 #define DEVICE_WIDE_STEREO (1<<16)
489 // Specifies if the device is currently running
490 #define DEVICE_RUNNING (1<<31)
492 /* Invalid channel offset */
493 #define INVALID_OFFSET (~0u)
496 /* Must be less than 15 characters (16 including terminating null) for
497 * compatibility with pthread_setname_np limitations. */
498 #define MIXER_THREAD_NAME "alsoft-mixer"
501 struct ALCcontext_struct
503 volatile RefCount ref;
505 struct ALlistener *Listener;
507 UIntMap SourceMap;
508 UIntMap EffectSlotMap;
510 volatile ALenum LastError;
512 volatile ALenum UpdateSources;
514 volatile enum DistanceModel DistanceModel;
515 volatile ALboolean SourceDistanceModel;
517 volatile ALfloat DopplerFactor;
518 volatile ALfloat DopplerVelocity;
519 volatile ALfloat SpeedOfSound;
520 volatile ALenum DeferUpdates;
522 struct ALsource **ActiveSources;
523 ALsizei ActiveSourceCount;
524 ALsizei MaxActiveSources;
526 struct ALeffectslot **ActiveEffectSlots;
527 ALsizei ActiveEffectSlotCount;
528 ALsizei MaxActiveEffectSlots;
530 ALCdevice *Device;
531 const ALCchar *ExtensionList;
533 ALCcontext *volatile next;
536 ALCcontext *GetContextRef(void);
538 void ALCcontext_IncRef(ALCcontext *context);
539 void ALCcontext_DecRef(ALCcontext *context);
541 void AppendAllDevicesList(const ALCchar *name);
542 void AppendCaptureDeviceList(const ALCchar *name);
544 ALint64 ALCdevice_GetLatencyDefault(ALCdevice *device);
546 void ALCdevice_Lock(ALCdevice *device);
547 void ALCdevice_Unlock(ALCdevice *device);
548 ALint64 ALCdevice_GetLatency(ALCdevice *device);
550 inline void LockContext(ALCcontext *context)
551 { ALCdevice_Lock(context->Device); }
553 inline void UnlockContext(ALCcontext *context)
554 { ALCdevice_Unlock(context->Device); }
557 void *al_malloc(size_t alignment, size_t size);
558 void *al_calloc(size_t alignment, size_t size);
559 void al_free(void *ptr);
562 typedef struct {
563 #ifdef HAVE_FENV_H
564 DERIVE_FROM_TYPE(fenv_t);
565 #else
566 int state;
567 #endif
568 #ifdef HAVE_SSE
569 int sse_state;
570 #endif
571 } FPUCtl;
572 void SetMixerFPUMode(FPUCtl *ctl);
573 void RestoreFPUMode(const FPUCtl *ctl);
576 typedef struct RingBuffer RingBuffer;
577 RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
578 void DestroyRingBuffer(RingBuffer *ring);
579 ALsizei RingBufferSize(RingBuffer *ring);
580 void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
581 void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
583 void ReadALConfig(void);
584 void FreeALConfig(void);
585 int ConfigValueExists(const char *blockName, const char *keyName);
586 const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
587 int GetConfigValueBool(const char *blockName, const char *keyName, int def);
588 int ConfigValueStr(const char *blockName, const char *keyName, const char **ret);
589 int ConfigValueInt(const char *blockName, const char *keyName, int *ret);
590 int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret);
591 int ConfigValueFloat(const char *blockName, const char *keyName, float *ret);
593 void SetRTPriority(void);
595 void SetDefaultChannelOrder(ALCdevice *device);
596 void SetDefaultWFXChannelOrder(ALCdevice *device);
598 const ALCchar *DevFmtTypeString(enum DevFmtType type);
599 const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans);
601 #define HRIR_BITS (7)
602 #define HRIR_LENGTH (1<<HRIR_BITS)
603 #define HRIR_MASK (HRIR_LENGTH-1)
604 #define HRTFDELAY_BITS (20)
605 #define HRTFDELAY_FRACONE (1<<HRTFDELAY_BITS)
606 #define HRTFDELAY_MASK (HRTFDELAY_FRACONE-1)
607 const struct Hrtf *GetHrtf(ALCdevice *device);
608 void FindHrtfFormat(const ALCdevice *device, enum DevFmtChannels *chans, ALCuint *srate);
609 void FreeHrtfs(void);
610 ALuint GetHrtfIrSize(const struct Hrtf *Hrtf);
611 ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]);
612 void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays);
613 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);
616 extern FILE *LogFile;
618 #ifdef __GNUC__
619 #define AL_PRINT(T, MSG, ...) fprintf(LogFile, "AL lib: %s %s: "MSG, T, __FUNCTION__ , ## __VA_ARGS__)
620 #else
621 void al_print(const char *type, const char *func, const char *fmt, ...) PRINTF_STYLE(3,4);
622 #define AL_PRINT(T, MSG, ...) al_print((T), __FUNCTION__, MSG, __VA_ARGS__)
623 #endif
625 enum LogLevel {
626 NoLog,
627 LogError,
628 LogWarning,
629 LogTrace,
630 LogRef
632 extern enum LogLevel LogLevel;
634 #define TRACEREF(...) do { \
635 if(LogLevel >= LogRef) \
636 AL_PRINT("(--)", __VA_ARGS__); \
637 } while(0)
639 #define TRACE(...) do { \
640 if(LogLevel >= LogTrace) \
641 AL_PRINT("(II)", __VA_ARGS__); \
642 } while(0)
644 #define WARN(...) do { \
645 if(LogLevel >= LogWarning) \
646 AL_PRINT("(WW)", __VA_ARGS__); \
647 } while(0)
649 #define ERR(...) do { \
650 if(LogLevel >= LogError) \
651 AL_PRINT("(EE)", __VA_ARGS__); \
652 } while(0)
655 extern ALint RTPrioLevel;
658 extern ALuint CPUCapFlags;
659 enum {
660 CPU_CAP_SSE = 1<<0,
661 CPU_CAP_SSE2 = 1<<1,
662 CPU_CAP_NEON = 1<<2,
665 void FillCPUCaps(ALuint capfilter);
668 #define SET_ERROR_AND_RETURN(ctx, err) do { \
669 alSetError((ctx), (err)); \
670 return; \
671 } while(0)
673 #define SET_ERROR_AND_RETURN_VALUE(ctx, err, val) do { \
674 alSetError((ctx), (err)); \
675 return (val); \
676 } while(0)
678 #define SET_ERROR_AND_GOTO(ctx, err, lbl) do { \
679 alSetError((ctx), (err)); \
680 goto lbl; \
681 } while(0)
684 /* Small hack to use a pointer-to-array type as a normal argument type.
685 * Shouldn't be used directly. */
686 typedef ALfloat ALfloatBUFFERSIZE[BUFFERSIZE];
689 #ifdef __cplusplus
691 #endif
693 #endif