26 #define ALC_SOFT_HRTF 1
27 #define ALC_HRTF_SOFT 0x1992
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_MIDI_PRESET_SOFT 0x9997
35 #define AL_MIDI_BANK_SOFT 0x9996
36 #define AL_PRESETS_SIZE_SOFT 0x9995
37 #define AL_PRESETS_SOFT 0x9994
38 #define AL_FONTSOUNDS_SIZE_SOFT 0x9993
39 #define AL_FONTSOUNDS_SOFT 0x9992
40 #define AL_KEY_RANGE_SOFT 0x002B
41 #define AL_VELOCITY_RANGE_SOFT 0x002C
42 #define AL_FORMAT_TYPE_SOFT 0x1991
43 #define AL_NOTEOFF_SOFT 0x0080
44 #define AL_NOTEON_SOFT 0x0090
45 #define AL_AFTERTOUCH_SOFT 0x00A0
46 #define AL_CONTROLLERCHANGE_SOFT 0x00B0
47 #define AL_PROGRAMCHANGE_SOFT 0x00C0
48 #define AL_CHANNELPRESSURE_SOFT 0x00D0
49 #define AL_PITCHBEND_SOFT 0x00E0
50 typedef void (AL_APIENTRY
*LPALGENSOUNDFONTSSOFT
)(ALsizei n
, ALuint
*ids
);
51 typedef void (AL_APIENTRY
*LPALDELETESOUNDFONTSSOFT
)(ALsizei n
, const ALuint
*ids
);
52 typedef ALboolean (AL_APIENTRY
*LPALISSOUNDFONTSOFT
)(ALuint id
);
53 typedef void (AL_APIENTRY
*LPALSOUNDFONTSAMPLESSOFT
)(ALuint sfid
, ALenum type
, ALsizei count
, const ALvoid
*samples
);
54 typedef ALvoid
* (AL_APIENTRY
*LPALSOUNDFONTMAPSAMPLESSOFT
)(ALuint sfid
, ALsizei offset
, ALsizei length
);
55 typedef void (AL_APIENTRY
*LPALSOUNDFONTUNMAPSAMPLESSOFT
)(ALuint sfid
);
56 typedef void (AL_APIENTRY
*LPALGETSOUNDFONTIVSOFT
)(ALuint id
, ALenum param
, ALint
*values
);
57 typedef void (AL_APIENTRY
*LPALSOUNDFONTPRESETSSOFT
)(ALuint id
, ALsizei count
, const ALuint
*pids
);
58 typedef void (AL_APIENTRY
*LPALGENPRESETSSOFT
)(ALsizei n
, ALuint
*ids
);
59 typedef void (AL_APIENTRY
*LPALDELETEPRESETSSOFT
)(ALsizei n
, const ALuint
*ids
);
60 typedef ALboolean (AL_APIENTRY
*LPALISPRESETSOFT
)(ALuint id
);
61 typedef void (AL_APIENTRY
*LPALPRESETISOFT
)(ALuint id
, ALenum param
, ALint value
);
62 typedef void (AL_APIENTRY
*LPALPRESETIVSOFT
)(ALuint id
, ALenum param
, const ALint
*values
);
63 typedef void (AL_APIENTRY
*LPALPRESETFONTSOUNDSSOFT
)(ALuint id
, ALsizei count
, const ALuint
*fsids
);
64 typedef void (AL_APIENTRY
*LPALGETPRESETIVSOFT
)(ALuint id
, ALenum param
, ALint
*values
);
65 typedef void (AL_APIENTRY
*LPALGENFONTSOUNDSSOFT
)(ALsizei n
, ALuint
*ids
);
66 typedef void (AL_APIENTRY
*LPALDELETEFONTSOUNDSSOFT
)(ALsizei n
, const ALuint
*ids
);
67 typedef ALboolean (AL_APIENTRY
*LPALISFONTSOUNDSOFT
)(ALuint id
);
68 typedef void (AL_APIENTRY
*LPALFONTSOUNDISOFT
)(ALuint id
, ALenum param
, ALint value
);
69 typedef void (AL_APIENTRY
*LPALFONTSOUND2ISOFT
)(ALuint id
, ALenum param
, ALint value1
, ALint value2
);
70 typedef void (AL_APIENTRY
*LPALFONTSOUNDIVSOFT
)(ALuint id
, ALenum param
, const ALint
*values
);
71 typedef void (AL_APIENTRY
*LPALGETFONTSOUNDIVSOFT
)(ALuint id
, ALenum param
, ALint
*values
);
72 typedef void (AL_APIENTRY
*LPALMIDISOUNDFONTSOFT
)(const char *filename
);
73 typedef void (AL_APIENTRY
*LPALMIDIEVENTSOFT
)(ALuint64SOFT time
, ALenum event
, ALsizei channel
, ALsizei param1
, ALsizei param2
);
74 typedef void (AL_APIENTRY
*LPALMIDISYSEXSOFT
)(ALuint64SOFT time
, const ALbyte
*data
, ALsizei size
);
75 typedef void (AL_APIENTRY
*LPALMIDIPLAYSOFT
)(void);
76 typedef void (AL_APIENTRY
*LPALMIDIPAUSESOFT
)(void);
77 typedef void (AL_APIENTRY
*LPALMIDISTOPSOFT
)(void);
78 typedef void (AL_APIENTRY
*LPALMIDIRESETSOFT
)(void);
79 typedef void (AL_APIENTRY
*LPALMIDIGAINSOFT
)(ALfloat value
);
80 typedef ALint64SOFT (AL_APIENTRY
*LPALGETINTEGER64SOFT
)(ALenum pname
);
81 typedef void (AL_APIENTRY
*LPALGETINTEGER64VSOFT
)(ALenum pname
, ALint64SOFT
*values
);
82 #ifdef AL_ALEXT_PROTOTYPES
83 AL_API
void AL_APIENTRY
alGenSoundfontsSOFT(ALsizei n
, ALuint
*ids
);
84 AL_API
void AL_APIENTRY
alDeleteSoundfontsSOFT(ALsizei n
, const ALuint
*ids
);
85 AL_API ALboolean AL_APIENTRY
alIsSoundfontSOFT(ALuint id
);
86 AL_API
void AL_APIENTRY
alSoundfontSamplesSOFT(ALuint sfid
, ALenum type
, ALsizei count
, const ALvoid
*samples
);
87 AL_API ALvoid
* AL_APIENTRY
alSoundfontMapSamplesSOFT(ALuint sfid
, ALsizei offset
, ALsizei length
);
88 AL_API
void AL_APIENTRY
alSoundfontUnmapSamplesSOFT(ALuint sfid
);
89 AL_API
void AL_APIENTRY
alGetSoundfontivSOFT(ALuint id
, ALenum param
, ALint
*values
);
90 AL_API
void AL_APIENTRY
alSoundfontPresetsSOFT(ALuint id
, ALsizei count
, const ALuint
*pids
);
92 AL_API
void AL_APIENTRY
alGenPresetsSOFT(ALsizei n
, ALuint
*ids
);
93 AL_API
void AL_APIENTRY
alDeletePresetsSOFT(ALsizei n
, const ALuint
*ids
);
94 AL_API ALboolean AL_APIENTRY
alIsPresetSOFT(ALuint id
);
95 AL_API
void AL_APIENTRY
alPresetiSOFT(ALuint id
, ALenum param
, ALint value
);
96 AL_API
void AL_APIENTRY
alPresetivSOFT(ALuint id
, ALenum param
, const ALint
*values
);
97 AL_API
void AL_APIENTRY
alGetPresetivSOFT(ALuint id
, ALenum param
, ALint
*values
);
98 AL_API
void AL_APIENTRY
alPresetFontsoundsSOFT(ALuint id
, ALsizei count
, const ALuint
*fsids
);
100 AL_API
void AL_APIENTRY
alGenFontsoundsSOFT(ALsizei n
, ALuint
*ids
);
101 AL_API
void AL_APIENTRY
alDeleteFontsoundsSOFT(ALsizei n
, const ALuint
*ids
);
102 AL_API ALboolean AL_APIENTRY
alIsFontsoundSOFT(ALuint id
);
103 AL_API
void AL_APIENTRY
alFontsoundiSOFT(ALuint id
, ALenum param
, ALint value
);
104 AL_API
void AL_APIENTRY
alFontsound2iSOFT(ALuint id
, ALenum param
, ALint value1
, ALint value2
);
105 AL_API
void AL_APIENTRY
alFontsoundivSOFT(ALuint id
, ALenum param
, const ALint
*values
);
106 AL_API
void AL_APIENTRY
alGetFontsoundivSOFT(ALuint id
, ALenum param
, ALint
*values
);
108 AL_API
void AL_APIENTRY
alMidiSoundfontSOFT(const char *filename
);
109 AL_API
void AL_APIENTRY
alMidiEventSOFT(ALuint64SOFT time
, ALenum event
, ALsizei channel
, ALsizei param1
, ALsizei param2
);
110 AL_API
void AL_APIENTRY
alMidiSysExSOFT(ALuint64SOFT time
, const ALbyte
*data
, ALsizei size
);
111 AL_API
void AL_APIENTRY
alMidiPlaySOFT(void);
112 AL_API
void AL_APIENTRY
alMidiPauseSOFT(void);
113 AL_API
void AL_APIENTRY
alMidiStopSOFT(void);
114 AL_API
void AL_APIENTRY
alMidiResetSOFT(void);
115 AL_API
void AL_APIENTRY
alMidiGainSOFT(ALfloat value
);
116 AL_API ALint64SOFT AL_APIENTRY
alGetInteger64SOFT(ALenum pname
);
117 AL_API
void AL_APIENTRY
alGetInteger64vSOFT(ALenum pname
, ALint64SOFT
*values
);
123 /* KDevelop's parser doesn't recognize the C99-standard restrict keyword, but
124 * recent versions (at least 4.5.1) do recognize GCC's __restrict. */
125 #define restrict __restrict
126 /* KDevelop won't see the ALIGN macro from config.h when viewing files that
127 * don't include it directly (e.g. headers). */
134 typedef ALint64SOFT ALint64
;
135 typedef ALuint64SOFT ALuint64
;
137 typedef ptrdiff_t ALintptrEXT
;
138 typedef ptrdiff_t ALsizeiptrEXT
;
141 #if defined(_MSC_VER)
142 #define U64(x) ((ALuint64)(x##ui64))
143 #elif SIZEOF_LONG == 8
144 #define U64(x) ((ALuint64)(x##ul))
145 #elif SIZEOF_LONG_LONG == 8
146 #define U64(x) ((ALuint64)(x##ull))
151 #define UINT64_MAX U64(18446744073709551615)
155 #if defined(__cplusplus)
157 #elif defined(__GNUC__)
158 #define UNUSED(x) UNUSED_##x __attribute__((unused))
159 #elif defined(__LCLINT__)
160 #define UNUSED(x) /*@unused@*/ x
166 #ifdef HAVE_GCC_FORMAT
167 #define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y))))
169 #define PRINTF_STYLE(x, y)
172 #if defined(__GNUC__) && defined(__i386__)
173 /* force_align_arg_pointer is required for proper function arguments aligning
174 * when SSE code is used. Some systems (Windows, QNX) do not guarantee our
175 * thread functions will be properly aligned on the stack, even though GCC may
176 * generate code with the assumption that it is. */
177 #define FORCE_ALIGN __attribute__((force_align_arg_pointer))
185 ALubyte b
[sizeof(ALuint
)];
186 } EndianTest
= { 1 };
187 #define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
189 #define COUNTOF(x) (sizeof((x))/sizeof((x)[0]))
192 #define DERIVE_FROM_TYPE(t) t t##_parent
193 #define STATIC_CAST(to, obj) (&(obj)->to##_parent)
194 #define STATIC_UPCAST(to, from, obj) ((to*)((char*)(obj) - offsetof(to, from##_parent)))
197 #define DECLARE_FORWARD(T1, T2, rettype, func) \
198 rettype T1##_##func(T1 *obj) \
199 { return T2##_##func(STATIC_CAST(T2, obj)); }
201 #define DECLARE_FORWARD1(T1, T2, rettype, func, argtype1) \
202 rettype T1##_##func(T1 *obj, argtype1 a) \
203 { return T2##_##func(STATIC_CAST(T2, obj), a); }
205 #define DECLARE_FORWARD2(T1, T2, rettype, func, argtype1, argtype2) \
206 rettype T1##_##func(T1 *obj, argtype1 a, argtype2 b) \
207 { return T2##_##func(STATIC_CAST(T2, obj), a, b); }
210 #define GET_VTABLE1(T1) (&(T1##_vtable))
211 #define GET_VTABLE2(T1, T2) (&(T1##_##T2##_vtable))
213 #define SET_VTABLE1(T1, obj) ((obj)->vtbl = GET_VTABLE1(T1))
214 #define SET_VTABLE2(T1, T2, obj) (STATIC_CAST(T2, obj)->vtbl = GET_VTABLE2(T1, T2))
216 #define DECLARE_THUNK(T1, T2, rettype, func) \
217 static rettype T1##_##T2##_##func(T2 *obj) \
218 { return T1##_##func(STATIC_UPCAST(T1, T2, obj)); }
220 #define DECLARE_THUNK1(T1, T2, rettype, func, argtype1) \
221 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a) \
222 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a); }
224 #define DECLARE_THUNK2(T1, T2, rettype, func, argtype1, argtype2) \
225 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b) \
226 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b); }
228 #define DECLARE_THUNK3(T1, T2, rettype, func, argtype1, argtype2, argtype3) \
229 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b, argtype3 c) \
230 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b, c); }
233 /* Helper to extract an argument list for VCALL. Not used directly. */
234 #define EXTRACT_VCALL_ARGS(...) __VA_ARGS__))
236 /* Call a "virtual" method on an object, with arguments. */
237 #define V(obj, func) ((obj)->vtbl->func((obj), EXTRACT_VCALL_ARGS
238 /* Call a "virtual" method on an object, with no arguments. */
239 #define V0(obj, func) ((obj)->vtbl->func((obj) EXTRACT_VCALL_ARGS
241 #define DELETE_OBJ(obj) do { \
244 V0((obj),Destruct)(); \
245 V0((obj),Delete)(); \
257 #define DEFAULT_OUTPUT_RATE (44100)
258 #define MIN_OUTPUT_RATE (8000)
261 /* Find the next power-of-2 for non-power-of-2 numbers. */
262 inline ALuint
NextPowerOf2(ALuint value
)
276 /* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
278 inline ALint
fastf2i(ALfloat f
)
282 #elif defined(_MSC_VER) && defined(_M_IX86)
292 /* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
294 inline ALuint
fastf2u(ALfloat f
)
295 { return fastf2i(f
); }
304 ALCenum (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
305 void (*ClosePlayback
)(ALCdevice
*);
306 ALCboolean (*ResetPlayback
)(ALCdevice
*);
307 ALCboolean (*StartPlayback
)(ALCdevice
*);
308 void (*StopPlayback
)(ALCdevice
*);
310 ALCenum (*OpenCapture
)(ALCdevice
*, const ALCchar
*);
311 void (*CloseCapture
)(ALCdevice
*);
312 void (*StartCapture
)(ALCdevice
*);
313 void (*StopCapture
)(ALCdevice
*);
314 ALCenum (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
315 ALCuint (*AvailableSamples
)(ALCdevice
*);
317 ALint64 (*GetLatency
)(ALCdevice
*);
320 ALCboolean
alc_solaris_init(BackendFuncs
*func_list
);
321 void alc_solaris_deinit(void);
322 void alc_solaris_probe(enum DevProbe type
);
323 ALCboolean
alc_sndio_init(BackendFuncs
*func_list
);
324 void alc_sndio_deinit(void);
325 void alc_sndio_probe(enum DevProbe type
);
326 ALCboolean
alcMMDevApiInit(BackendFuncs
*func_list
);
327 void alcMMDevApiDeinit(void);
328 void alcMMDevApiProbe(enum DevProbe type
);
329 ALCboolean
alcDSoundInit(BackendFuncs
*func_list
);
330 void alcDSoundDeinit(void);
331 void alcDSoundProbe(enum DevProbe type
);
332 ALCboolean
alcWinMMInit(BackendFuncs
*FuncList
);
333 void alcWinMMDeinit(void);
334 void alcWinMMProbe(enum DevProbe type
);
335 ALCboolean
alc_pa_init(BackendFuncs
*func_list
);
336 void alc_pa_deinit(void);
337 void alc_pa_probe(enum DevProbe type
);
338 ALCboolean
alc_wave_init(BackendFuncs
*func_list
);
339 void alc_wave_deinit(void);
340 void alc_wave_probe(enum DevProbe type
);
341 ALCboolean
alc_ca_init(BackendFuncs
*func_list
);
342 void alc_ca_deinit(void);
343 void alc_ca_probe(enum DevProbe type
);
344 ALCboolean
alc_opensl_init(BackendFuncs
*func_list
);
345 void alc_opensl_deinit(void);
346 void alc_opensl_probe(enum DevProbe type
);
347 ALCboolean
alc_qsa_init(BackendFuncs
*func_list
);
348 void alc_qsa_deinit(void);
349 void alc_qsa_probe(enum DevProbe type
);
355 InverseDistanceClamped
= AL_INVERSE_DISTANCE_CLAMPED
,
356 LinearDistanceClamped
= AL_LINEAR_DISTANCE_CLAMPED
,
357 ExponentDistanceClamped
= AL_EXPONENT_DISTANCE_CLAMPED
,
358 InverseDistance
= AL_INVERSE_DISTANCE
,
359 LinearDistance
= AL_LINEAR_DISTANCE
,
360 ExponentDistance
= AL_EXPONENT_DISTANCE
,
361 DisableDistance
= AL_NONE
,
363 DefaultDistanceModel
= InverseDistanceClamped
391 DevFmtByte
= ALC_BYTE_SOFT
,
392 DevFmtUByte
= ALC_UNSIGNED_BYTE_SOFT
,
393 DevFmtShort
= ALC_SHORT_SOFT
,
394 DevFmtUShort
= ALC_UNSIGNED_SHORT_SOFT
,
395 DevFmtInt
= ALC_INT_SOFT
,
396 DevFmtUInt
= ALC_UNSIGNED_INT_SOFT
,
397 DevFmtFloat
= ALC_FLOAT_SOFT
,
399 DevFmtTypeDefault
= DevFmtFloat
401 enum DevFmtChannels
{
402 DevFmtMono
= ALC_MONO_SOFT
,
403 DevFmtStereo
= ALC_STEREO_SOFT
,
404 DevFmtQuad
= ALC_QUAD_SOFT
,
405 DevFmtX51
= ALC_5POINT1_SOFT
,
406 DevFmtX61
= ALC_6POINT1_SOFT
,
407 DevFmtX71
= ALC_7POINT1_SOFT
,
409 /* Similar to 5.1, except using the side channels instead of back */
410 DevFmtX51Side
= 0x80000000,
412 DevFmtChannelsDefault
= DevFmtStereo
415 ALuint
BytesFromDevFmt(enum DevFmtType type
);
416 ALuint
ChannelsFromDevFmt(enum DevFmtChannels chans
);
417 inline ALuint
FrameSizeFromDevFmt(enum DevFmtChannels chans
, enum DevFmtType type
)
419 return ChannelsFromDevFmt(chans
) * BytesFromDevFmt(type
);
423 extern const struct EffectList
{
438 /* Size for temporary storage of buffer data, in ALfloats. Larger values need
439 * more memory, while smaller values may need more iterations. The value needs
440 * to be a sensible size, however, as it constrains the max stepping value used
441 * for mixing, as well as the maximum number of samples per mixing iteration.
443 #define BUFFERSIZE (2048u)
446 struct ALCdevice_struct
448 volatile RefCount ref
;
450 ALCboolean Connected
;
451 enum DeviceType Type
;
456 enum DevFmtChannels FmtChans
;
457 enum DevFmtType FmtType
;
461 volatile ALCenum LastError
;
463 // Maximum number of sources that can be created
464 ALuint MaxNoOfSources
;
465 // Maximum number of slots that can be created
466 ALuint AuxiliaryEffectSlotMax
;
468 ALCuint NumMonoSources
;
469 ALCuint NumStereoSources
;
472 // Map of Buffers for this device
475 // Map of Effects for this device
478 // Map of Filters for this device
481 // Map of Soundfonts for this device
484 // Map of Presets for this device
487 // Map of Fontsounds for this device
488 UIntMap FontsoundMap
;
490 /* MIDI synth engine */
491 struct MidiSynth
*Synth
;
493 /* HRTF filter tables */
494 const struct Hrtf
*Hrtf
;
496 // Stereo-to-binaural filter
503 ALuint ChannelOffsets
[MaxChannels
];
505 enum Channel Speaker2Chan
[MaxChannels
];
506 ALfloat SpeakerAngle
[MaxChannels
];
509 /* Temp storage used for mixing. +1 for the predictive sample. */
510 ALIGN(16) ALfloat SampleData1
[BUFFERSIZE
+1];
511 ALIGN(16) ALfloat SampleData2
[BUFFERSIZE
+1];
513 // Dry path buffer mix
514 ALIGN(16) ALfloat DryBuffer
[MaxChannels
][BUFFERSIZE
];
516 ALIGN(16) ALfloat ClickRemoval
[MaxChannels
];
517 ALIGN(16) ALfloat PendingClicks
[MaxChannels
];
519 /* Default effect slot */
520 struct ALeffectslot
*DefaultSlot
;
522 // Contexts created on this device
523 ALCcontext
*volatile ContextList
;
525 struct ALCbackend
*Backend
;
528 void *ExtraData
; // For the backend's use
530 ALCdevice
*volatile next
;
533 // Frequency was requested by the app or config file
534 #define DEVICE_FREQUENCY_REQUEST (1<<1)
535 // Channel configuration was requested by the config file
536 #define DEVICE_CHANNELS_REQUEST (1<<2)
537 // Sample type was requested by the config file
538 #define DEVICE_SAMPLE_TYPE_REQUEST (1<<3)
539 // HRTF was requested by the app
540 #define DEVICE_HRTF_REQUEST (1<<4)
542 // Stereo sources cover 120-degree angles around +/-90
543 #define DEVICE_WIDE_STEREO (1<<16)
545 // Specifies if the device is currently running
546 #define DEVICE_RUNNING (1<<31)
548 /* Invalid channel offset */
549 #define INVALID_OFFSET (~0u)
552 /* Must be less than 15 characters (16 including terminating null) for
553 * compatibility with pthread_setname_np limitations. */
554 #define MIXER_THREAD_NAME "alsoft-mixer"
557 struct ALCcontext_struct
559 volatile RefCount ref
;
561 struct ALlistener
*Listener
;
564 UIntMap EffectSlotMap
;
566 volatile ALenum LastError
;
568 volatile ALenum UpdateSources
;
570 volatile enum DistanceModel DistanceModel
;
571 volatile ALboolean SourceDistanceModel
;
573 volatile ALfloat DopplerFactor
;
574 volatile ALfloat DopplerVelocity
;
575 volatile ALfloat SpeedOfSound
;
576 volatile ALenum DeferUpdates
;
578 struct ALsource
**ActiveSources
;
579 ALsizei ActiveSourceCount
;
580 ALsizei MaxActiveSources
;
582 struct ALeffectslot
**ActiveEffectSlots
;
583 ALsizei ActiveEffectSlotCount
;
584 ALsizei MaxActiveEffectSlots
;
587 const ALCchar
*ExtensionList
;
589 ALCcontext
*volatile next
;
592 ALCcontext
*GetContextRef(void);
594 void ALCcontext_IncRef(ALCcontext
*context
);
595 void ALCcontext_DecRef(ALCcontext
*context
);
597 void AppendAllDevicesList(const ALCchar
*name
);
598 void AppendCaptureDeviceList(const ALCchar
*name
);
600 ALint64
ALCdevice_GetLatencyDefault(ALCdevice
*device
);
602 void ALCdevice_Lock(ALCdevice
*device
);
603 void ALCdevice_Unlock(ALCdevice
*device
);
604 ALint64
ALCdevice_GetLatency(ALCdevice
*device
);
606 inline void LockContext(ALCcontext
*context
)
607 { ALCdevice_Lock(context
->Device
); }
609 inline void UnlockContext(ALCcontext
*context
)
610 { ALCdevice_Unlock(context
->Device
); }
613 void *al_malloc(size_t alignment
, size_t size
);
614 void *al_calloc(size_t alignment
, size_t size
);
615 void al_free(void *ptr
);
620 DERIVE_FROM_TYPE(fenv_t
);
628 void SetMixerFPUMode(FPUCtl
*ctl
);
629 void RestoreFPUMode(const FPUCtl
*ctl
);
632 typedef struct RingBuffer RingBuffer
;
633 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
634 void DestroyRingBuffer(RingBuffer
*ring
);
635 ALsizei
RingBufferSize(RingBuffer
*ring
);
636 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
637 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
639 void ReadALConfig(void);
640 void FreeALConfig(void);
641 int ConfigValueExists(const char *blockName
, const char *keyName
);
642 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
643 int GetConfigValueBool(const char *blockName
, const char *keyName
, int def
);
644 int ConfigValueStr(const char *blockName
, const char *keyName
, const char **ret
);
645 int ConfigValueInt(const char *blockName
, const char *keyName
, int *ret
);
646 int ConfigValueUInt(const char *blockName
, const char *keyName
, unsigned int *ret
);
647 int ConfigValueFloat(const char *blockName
, const char *keyName
, float *ret
);
649 void SetRTPriority(void);
651 void SetDefaultChannelOrder(ALCdevice
*device
);
652 void SetDefaultWFXChannelOrder(ALCdevice
*device
);
654 const ALCchar
*DevFmtTypeString(enum DevFmtType type
);
655 const ALCchar
*DevFmtChannelsString(enum DevFmtChannels chans
);
657 #define HRIR_BITS (7)
658 #define HRIR_LENGTH (1<<HRIR_BITS)
659 #define HRIR_MASK (HRIR_LENGTH-1)
660 #define HRTFDELAY_BITS (20)
661 #define HRTFDELAY_FRACONE (1<<HRTFDELAY_BITS)
662 #define HRTFDELAY_MASK (HRTFDELAY_FRACONE-1)
663 const struct Hrtf
*GetHrtf(ALCdevice
*device
);
664 void FindHrtfFormat(const ALCdevice
*device
, enum DevFmtChannels
*chans
, ALCuint
*srate
);
665 void FreeHrtfs(void);
666 ALuint
GetHrtfIrSize(const struct Hrtf
*Hrtf
);
667 ALfloat
CalcHrtfDelta(ALfloat oldGain
, ALfloat newGain
, const ALfloat olddir
[3], const ALfloat newdir
[3]);
668 void GetLerpedHrtfCoeffs(const struct Hrtf
*Hrtf
, ALfloat elevation
, ALfloat azimuth
, ALfloat gain
, ALfloat (*coeffs
)[2], ALuint
*delays
);
669 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
);
672 extern FILE *LogFile
;
675 #define AL_PRINT(T, MSG, ...) fprintf(LogFile, "AL lib: %s %s: "MSG, T, __FUNCTION__ , ## __VA_ARGS__)
677 void al_print(const char *type
, const char *func
, const char *fmt
, ...) PRINTF_STYLE(3,4);
678 #define AL_PRINT(T, MSG, ...) al_print((T), __FUNCTION__, MSG, __VA_ARGS__)
688 extern enum LogLevel LogLevel
;
690 #define TRACEREF(...) do { \
691 if(LogLevel >= LogRef) \
692 AL_PRINT("(--)", __VA_ARGS__); \
695 #define TRACE(...) do { \
696 if(LogLevel >= LogTrace) \
697 AL_PRINT("(II)", __VA_ARGS__); \
700 #define WARN(...) do { \
701 if(LogLevel >= LogWarning) \
702 AL_PRINT("(WW)", __VA_ARGS__); \
705 #define ERR(...) do { \
706 if(LogLevel >= LogError) \
707 AL_PRINT("(EE)", __VA_ARGS__); \
711 extern ALint RTPrioLevel
;
714 extern ALuint CPUCapFlags
;
721 void FillCPUCaps(ALuint capfilter
);
724 #define SET_ERROR_AND_RETURN(ctx, err) do { \
725 alSetError((ctx), (err)); \
729 #define SET_ERROR_AND_RETURN_VALUE(ctx, err, val) do { \
730 alSetError((ctx), (err)); \
734 #define SET_ERROR_AND_GOTO(ctx, err, lbl) do { \
735 alSetError((ctx), (err)); \
740 /* Small hack to use a pointer-to-array type as a normal argument type.
741 * Shouldn't be used directly. */
742 typedef ALfloat ALfloatBUFFERSIZE
[BUFFERSIZE
];