33 #include "static_assert.h"
44 #ifndef ALC_SOFT_device_clock
45 #define ALC_SOFT_device_clock 1
46 typedef int64_t ALCint64SOFT
;
47 typedef uint64_t ALCuint64SOFT
;
48 #define ALC_DEVICE_CLOCK_SOFT 0x1600
49 #define ALC_DEVICE_LATENCY_SOFT 0x1601
50 #define ALC_DEVICE_CLOCK_LATENCY_SOFT 0x1602
51 typedef void (ALC_APIENTRY
*LPALCGETINTEGER64VSOFT
)(ALCdevice
*device
, ALCenum pname
, ALsizei size
, ALCint64SOFT
*values
);
52 #ifdef AL_ALEXT_PROTOTYPES
53 ALC_API
void ALC_APIENTRY
alcGetInteger64vSOFT(ALCdevice
*device
, ALCenum pname
, ALsizei size
, ALCint64SOFT
*values
);
57 #ifndef AL_SOFT_buffer_samples2
58 #define AL_SOFT_buffer_samples2 1
59 /* Channel configurations */
60 #define AL_MONO_SOFT 0x1500
61 #define AL_STEREO_SOFT 0x1501
62 #define AL_REAR_SOFT 0x1502
63 #define AL_QUAD_SOFT 0x1503
64 #define AL_5POINT1_SOFT 0x1504
65 #define AL_6POINT1_SOFT 0x1505
66 #define AL_7POINT1_SOFT 0x1506
67 #define AL_BFORMAT2D_SOFT 0x1507
68 #define AL_BFORMAT3D_SOFT 0x1508
71 #define AL_BYTE_SOFT 0x1400
72 #define AL_UNSIGNED_BYTE_SOFT 0x1401
73 #define AL_SHORT_SOFT 0x1402
74 #define AL_UNSIGNED_SHORT_SOFT 0x1403
75 #define AL_INT_SOFT 0x1404
76 #define AL_UNSIGNED_INT_SOFT 0x1405
77 #define AL_FLOAT_SOFT 0x1406
78 #define AL_DOUBLE_SOFT 0x1407
79 #define AL_BYTE3_SOFT 0x1408
80 #define AL_UNSIGNED_BYTE3_SOFT 0x1409
81 #define AL_MULAW_SOFT 0x140A
84 #define AL_MONO8_SOFT 0x1100
85 #define AL_MONO16_SOFT 0x1101
86 #define AL_MONO32F_SOFT 0x10010
87 #define AL_STEREO8_SOFT 0x1102
88 #define AL_STEREO16_SOFT 0x1103
89 #define AL_STEREO32F_SOFT 0x10011
90 #define AL_QUAD8_SOFT 0x1204
91 #define AL_QUAD16_SOFT 0x1205
92 #define AL_QUAD32F_SOFT 0x1206
93 #define AL_REAR8_SOFT 0x1207
94 #define AL_REAR16_SOFT 0x1208
95 #define AL_REAR32F_SOFT 0x1209
96 #define AL_5POINT1_8_SOFT 0x120A
97 #define AL_5POINT1_16_SOFT 0x120B
98 #define AL_5POINT1_32F_SOFT 0x120C
99 #define AL_6POINT1_8_SOFT 0x120D
100 #define AL_6POINT1_16_SOFT 0x120E
101 #define AL_6POINT1_32F_SOFT 0x120F
102 #define AL_7POINT1_8_SOFT 0x1210
103 #define AL_7POINT1_16_SOFT 0x1211
104 #define AL_7POINT1_32F_SOFT 0x1212
105 #define AL_BFORMAT2D_8_SOFT 0x20021
106 #define AL_BFORMAT2D_16_SOFT 0x20022
107 #define AL_BFORMAT2D_32F_SOFT 0x20023
108 #define AL_BFORMAT3D_8_SOFT 0x20031
109 #define AL_BFORMAT3D_16_SOFT 0x20032
110 #define AL_BFORMAT3D_32F_SOFT 0x20033
112 /* Buffer attributes */
113 #define AL_INTERNAL_FORMAT_SOFT 0x2008
114 #define AL_BYTE_LENGTH_SOFT 0x2009
115 #define AL_SAMPLE_LENGTH_SOFT 0x200A
116 #define AL_SEC_LENGTH_SOFT 0x200B
119 typedef void (AL_APIENTRY
*LPALBUFFERSAMPLESSOFT
)(ALuint
,ALuint
,ALenum
,ALsizei
,ALenum
,ALenum
,const ALvoid
*);
120 typedef void (AL_APIENTRY
*LPALGETBUFFERSAMPLESSOFT
)(ALuint
,ALsizei
,ALsizei
,ALenum
,ALenum
,ALvoid
*);
121 typedef ALboolean (AL_APIENTRY
*LPALISBUFFERFORMATSUPPORTEDSOFT
)(ALenum
);
122 #ifdef AL_ALEXT_PROTOTYPES
123 AL_API
void AL_APIENTRY
alBufferSamplesSOFT(ALuint buffer
, ALuint samplerate
, ALenum internalformat
, ALsizei samples
, ALenum channels
, ALenum type
, const ALvoid
*data
);
124 AL_API
void AL_APIENTRY
alGetBufferSamplesSOFT(ALuint buffer
, ALsizei offset
, ALsizei samples
, ALenum channels
, ALenum type
, ALvoid
*data
);
125 AL_API ALboolean AL_APIENTRY
alIsBufferFormatSupportedSOFT(ALenum format
);
130 #ifndef AL_SOFT_gain_clamp_ex
131 #define AL_SOFT_gain_clamp_ex 1
132 #define AL_GAIN_LIMIT_SOFT 0x200E
136 typedef ALint64SOFT ALint64
;
137 typedef ALuint64SOFT ALuint64
;
140 #if defined(_MSC_VER)
141 #define U64(x) ((ALuint64)(x##ui64))
142 #elif SIZEOF_LONG == 8
143 #define U64(x) ((ALuint64)(x##ul))
144 #elif SIZEOF_LONG_LONG == 8
145 #define U64(x) ((ALuint64)(x##ull))
150 #define UINT64_MAX U64(18446744073709551615)
154 #if defined(__cplusplus)
156 #elif defined(__GNUC__)
157 #define UNUSED(x) UNUSED_##x __attribute__((unused))
158 #elif defined(__LCLINT__)
159 #define UNUSED(x) /*@unused@*/ x
166 #define DECL_FORMAT(x, y, z) __attribute__((format(x, (y), (z))))
168 #define DECL_FORMAT(x, y, z)
171 #if defined(__GNUC__) && defined(__i386__)
172 /* force_align_arg_pointer is required for proper function arguments aligning
173 * when SSE code is used. Some systems (Windows, QNX) do not guarantee our
174 * thread functions will be properly aligned on the stack, even though GCC may
175 * generate code with the assumption that it is. */
176 #define FORCE_ALIGN __attribute__((force_align_arg_pointer))
182 #define DECL_VLA(T, _name, _size) T _name[(_size)]
184 #define DECL_VLA(T, _name, _size) T *_name = alloca((_size) * sizeof(T))
189 #define PATH_MAX MAX_PATH
191 #define PATH_MAX 4096
198 ALubyte b
[sizeof(ALuint
)];
199 } EndianTest
= { 1 };
200 #define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
202 #define COUNTOF(x) (sizeof((x))/sizeof((x)[0]))
205 #define DERIVE_FROM_TYPE(t) t t##_parent
206 #define STATIC_CAST(to, obj) (&(obj)->to##_parent)
208 #define STATIC_UPCAST(to, from, obj) __extension__({ \
209 static_assert(__builtin_types_compatible_p(from, __typeof(*(obj))), \
210 "Invalid upcast object from type"); \
211 (to*)((char*)(obj) - offsetof(to, from##_parent)); \
214 #define STATIC_UPCAST(to, from, obj) ((to*)((char*)(obj) - offsetof(to, from##_parent)))
217 #define DECLARE_FORWARD(T1, T2, rettype, func) \
218 rettype T1##_##func(T1 *obj) \
219 { return T2##_##func(STATIC_CAST(T2, obj)); }
221 #define DECLARE_FORWARD1(T1, T2, rettype, func, argtype1) \
222 rettype T1##_##func(T1 *obj, argtype1 a) \
223 { return T2##_##func(STATIC_CAST(T2, obj), a); }
225 #define DECLARE_FORWARD2(T1, T2, rettype, func, argtype1, argtype2) \
226 rettype T1##_##func(T1 *obj, argtype1 a, argtype2 b) \
227 { return T2##_##func(STATIC_CAST(T2, obj), a, b); }
229 #define DECLARE_FORWARD3(T1, T2, rettype, func, argtype1, argtype2, argtype3) \
230 rettype T1##_##func(T1 *obj, argtype1 a, argtype2 b, argtype3 c) \
231 { return T2##_##func(STATIC_CAST(T2, obj), a, b, c); }
234 #define GET_VTABLE1(T1) (&(T1##_vtable))
235 #define GET_VTABLE2(T1, T2) (&(T1##_##T2##_vtable))
237 #define SET_VTABLE1(T1, obj) ((obj)->vtbl = GET_VTABLE1(T1))
238 #define SET_VTABLE2(T1, T2, obj) (STATIC_CAST(T2, obj)->vtbl = GET_VTABLE2(T1, T2))
240 #define DECLARE_THUNK(T1, T2, rettype, func) \
241 static rettype T1##_##T2##_##func(T2 *obj) \
242 { return T1##_##func(STATIC_UPCAST(T1, T2, obj)); }
244 #define DECLARE_THUNK1(T1, T2, rettype, func, argtype1) \
245 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a) \
246 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a); }
248 #define DECLARE_THUNK2(T1, T2, rettype, func, argtype1, argtype2) \
249 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b) \
250 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b); }
252 #define DECLARE_THUNK3(T1, T2, rettype, func, argtype1, argtype2, argtype3) \
253 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b, argtype3 c) \
254 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b, c); }
256 #define DECLARE_THUNK4(T1, T2, rettype, func, argtype1, argtype2, argtype3, argtype4) \
257 static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b, argtype3 c, argtype4 d) \
258 { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b, c, d); }
260 #define DECLARE_DEFAULT_ALLOCATORS(T) \
261 static void* T##_New(size_t size) { return al_malloc(16, size); } \
262 static void T##_Delete(void *ptr) { al_free(ptr); }
264 /* Helper to extract an argument list for VCALL. Not used directly. */
265 #define EXTRACT_VCALL_ARGS(...) __VA_ARGS__))
267 /* Call a "virtual" method on an object, with arguments. */
268 #define V(obj, func) ((obj)->vtbl->func((obj), EXTRACT_VCALL_ARGS
269 /* Call a "virtual" method on an object, with no arguments. */
270 #define V0(obj, func) ((obj)->vtbl->func((obj) EXTRACT_VCALL_ARGS
272 #define DELETE_OBJ(obj) do { \
275 V0((obj),Destruct)(); \
276 V0((obj),Delete)(); \
281 #define EXTRACT_NEW_ARGS(...) __VA_ARGS__); \
285 #define NEW_OBJ(_res, T) do { \
286 _res = T##_New(sizeof(T)); \
289 memset(_res, 0, sizeof(T)); \
290 T##_Construct(_res, EXTRACT_NEW_ARGS
291 #define NEW_OBJ0(_res, T) do { \
292 _res = T##_New(sizeof(T)); \
295 memset(_res, 0, sizeof(T)); \
296 T##_Construct(_res EXTRACT_NEW_ARGS
306 #define DEFAULT_OUTPUT_RATE (44100)
307 #define MIN_OUTPUT_RATE (8000)
310 /* Find the next power-of-2 for non-power-of-2 numbers. */
311 inline ALuint
NextPowerOf2(ALuint value
)
325 /* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
327 inline ALint
fastf2i(ALfloat f
)
331 #elif defined(_MSC_VER) && defined(_M_IX86)
341 /* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
343 inline ALuint
fastf2u(ALfloat f
)
344 { return fastf2i(f
); }
353 ALCenum (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
354 void (*ClosePlayback
)(ALCdevice
*);
355 ALCboolean (*ResetPlayback
)(ALCdevice
*);
356 ALCboolean (*StartPlayback
)(ALCdevice
*);
357 void (*StopPlayback
)(ALCdevice
*);
359 ALCenum (*OpenCapture
)(ALCdevice
*, const ALCchar
*);
360 void (*CloseCapture
)(ALCdevice
*);
361 void (*StartCapture
)(ALCdevice
*);
362 void (*StopCapture
)(ALCdevice
*);
363 ALCenum (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
364 ALCuint (*AvailableSamples
)(ALCdevice
*);
367 ALCboolean
alc_sndio_init(BackendFuncs
*func_list
);
368 void alc_sndio_deinit(void);
369 void alc_sndio_probe(enum DevProbe type
);
370 ALCboolean
alc_ca_init(BackendFuncs
*func_list
);
371 void alc_ca_deinit(void);
372 void alc_ca_probe(enum DevProbe type
);
373 ALCboolean
alc_opensl_init(BackendFuncs
*func_list
);
374 void alc_opensl_deinit(void);
375 void alc_opensl_probe(enum DevProbe type
);
376 ALCboolean
alc_qsa_init(BackendFuncs
*func_list
);
377 void alc_qsa_deinit(void);
378 void alc_qsa_probe(enum DevProbe type
);
384 InverseDistanceClamped
= AL_INVERSE_DISTANCE_CLAMPED
,
385 LinearDistanceClamped
= AL_LINEAR_DISTANCE_CLAMPED
,
386 ExponentDistanceClamped
= AL_EXPONENT_DISTANCE_CLAMPED
,
387 InverseDistance
= AL_INVERSE_DISTANCE
,
388 LinearDistance
= AL_LINEAR_DISTANCE
,
389 ExponentDistance
= AL_EXPONENT_DISTANCE
,
390 DisableDistance
= AL_NONE
,
392 DefaultDistanceModel
= InverseDistanceClamped
438 DevFmtByte
= ALC_BYTE_SOFT
,
439 DevFmtUByte
= ALC_UNSIGNED_BYTE_SOFT
,
440 DevFmtShort
= ALC_SHORT_SOFT
,
441 DevFmtUShort
= ALC_UNSIGNED_SHORT_SOFT
,
442 DevFmtInt
= ALC_INT_SOFT
,
443 DevFmtUInt
= ALC_UNSIGNED_INT_SOFT
,
444 DevFmtFloat
= ALC_FLOAT_SOFT
,
446 DevFmtTypeDefault
= DevFmtFloat
448 enum DevFmtChannels
{
449 DevFmtMono
= ALC_MONO_SOFT
,
450 DevFmtStereo
= ALC_STEREO_SOFT
,
451 DevFmtQuad
= ALC_QUAD_SOFT
,
452 DevFmtX51
= ALC_5POINT1_SOFT
,
453 DevFmtX61
= ALC_6POINT1_SOFT
,
454 DevFmtX71
= ALC_7POINT1_SOFT
,
456 /* Similar to 5.1, except using rear channels instead of sides */
457 DevFmtX51Rear
= 0x80000000,
459 /* Ambisonic formats should be kept together */
464 DevFmtChannelsDefault
= DevFmtStereo
466 #define MAX_OUTPUT_CHANNELS (16)
468 ALuint
BytesFromDevFmt(enum DevFmtType type
);
469 ALuint
ChannelsFromDevFmt(enum DevFmtChannels chans
);
470 inline ALuint
FrameSizeFromDevFmt(enum DevFmtChannels chans
, enum DevFmtType type
)
472 return ChannelsFromDevFmt(chans
) * BytesFromDevFmt(type
);
476 AmbiFormat_FuMa
, /* FuMa channel order and normalization */
477 AmbiFormat_ACN_SN3D
, /* ACN channel order and SN3D normalization */
478 AmbiFormat_ACN_N3D
, /* ACN channel order and N3D normalization */
480 AmbiFormat_Default
= AmbiFormat_ACN_SN3D
484 extern const struct EffectList
{
506 /* The maximum number of Ambisonics coefficients. For a given order (o), the
507 * size needed will be (o+1)**2, thus zero-order has 1, first-order has 4,
508 * second-order has 9, third-order has 16, and fourth-order has 25.
510 #define MAX_AMBI_ORDER 3
511 #define MAX_AMBI_COEFFS ((MAX_AMBI_ORDER+1) * (MAX_AMBI_ORDER+1))
513 /* A bitmask of ambisonic channels with height information. If none of these
514 * channels are used/needed, there's no height (e.g. with most surround sound
515 * speaker setups). This only specifies up to 4th order, which is the highest
516 * order a 32-bit mask value can specify (a 64-bit mask could handle up to 7th
517 * order). This is ACN ordering, with bit 0 being ACN 0, etc.
519 #define AMBI_PERIPHONIC_MASK (0xfe7ce4)
521 /* The maximum number of Ambisonic coefficients for 2D (non-periphonic)
522 * representation. This is 2 per each order above zero-order, plus 1 for zero-
523 * order. Or simply, o*2 + 1.
525 #define MAX_AMBI2D_COEFFS (MAX_AMBI_ORDER*2 + 1)
528 typedef ALfloat ChannelConfig
[MAX_AMBI_COEFFS
];
529 typedef struct BFChannelConfig
{
534 typedef union AmbiConfig
{
535 /* Ambisonic coefficients for mixing to the dry buffer. */
536 ChannelConfig Coeffs
[MAX_OUTPUT_CHANNELS
];
537 /* Coefficient channel mapping for mixing to the dry buffer. */
538 BFChannelConfig Map
[MAX_OUTPUT_CHANNELS
];
542 #define HRTF_HISTORY_BITS (6)
543 #define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS)
544 #define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1)
546 typedef struct HrtfState
{
547 alignas(16) ALfloat History
[HRTF_HISTORY_LENGTH
];
548 alignas(16) ALfloat Values
[HRIR_LENGTH
][2];
551 typedef struct HrtfParams
{
552 alignas(16) ALfloat Coeffs
[HRIR_LENGTH
][2];
557 /* Size for temporary storage of buffer data, in ALfloats. Larger values need
558 * more memory, while smaller values may need more iterations. The value needs
559 * to be a sensible size, however, as it constrains the max stepping value used
560 * for mixing, as well as the maximum number of samples per mixing iteration.
562 #define BUFFERSIZE (2048u)
564 struct ALCdevice_struct
568 ALCboolean Connected
;
569 enum DeviceType Type
;
574 enum DevFmtChannels FmtChans
;
575 enum DevFmtType FmtType
;
576 ALboolean IsHeadphones
;
577 /* For DevFmtAmbi* output only, specifies the channel order and
580 enum AmbiFormat AmbiFmt
;
582 al_string DeviceName
;
584 ATOMIC(ALCenum
) LastError
;
586 // Maximum number of sources that can be created
588 // Maximum number of slots that can be created
589 ALuint AuxiliaryEffectSlotMax
;
591 ALCuint NumMonoSources
;
592 ALCuint NumStereoSources
;
595 // Map of Buffers for this device
598 // Map of Effects for this device
601 // Map of Filters for this device
604 /* HRTF filter tables */
606 vector_HrtfEntry List
;
609 const struct Hrtf
*Handle
;
611 /* HRTF filter state for dry buffer content */
612 alignas(16) ALfloat Values
[4][HRIR_LENGTH
][2];
613 alignas(16) ALfloat Coeffs
[4][HRIR_LENGTH
][2];
618 /* UHJ encoder state */
619 struct Uhj2Encoder
*Uhj_Encoder
;
621 /* High quality Ambisonic decoder */
622 struct BFormatDec
*AmbiDecoder
;
624 /* Stereo-to-binaural filter */
627 /* First-order ambisonic upsampler for higher-order output */
628 struct AmbiUpsampler
*AmbiUp
;
630 /* Rendering mode. */
631 enum RenderMode Render_Mode
;
639 /* Temp storage used for each source when mixing. */
640 alignas(16) ALfloat SourceData
[BUFFERSIZE
];
641 alignas(16) ALfloat ResampledData
[BUFFERSIZE
];
642 alignas(16) ALfloat FilteredData
[BUFFERSIZE
];
644 /* The "dry" path corresponds to the main output. */
647 /* Number of coefficients in each Ambi.Coeffs to mix together (4 for
648 * first-order, 9 for second-order, etc). If the count is 0, Ambi.Map
649 * is used instead to map each output to a coefficient index.
653 ALfloat (*Buffer
)[BUFFERSIZE
];
657 /* First-order ambisonics output, to be upsampled to the dry buffer if different. */
660 /* Will only be 4 or 0. */
663 ALfloat (*Buffer
)[BUFFERSIZE
];
667 /* "Real" output, which will be written to the device buffer. May alias the
671 enum Channel ChannelName
[MAX_OUTPUT_CHANNELS
];
673 ALfloat (*Buffer
)[BUFFERSIZE
];
677 /* Running count of the mixer invocations, in 31.1 fixed point. This
678 * actually increments *twice* when mixing, first at the start and then at
679 * the end, so the bottom bit indicates if the device is currently mixing
680 * and the upper bits indicates how many mixes have been done.
684 /* Default effect slot */
685 struct ALeffectslot
*DefaultSlot
;
687 // Contexts created on this device
688 ATOMIC(ALCcontext
*) ContextList
;
691 struct ALCbackend
*Backend
;
693 void *ExtraData
; // For the backend's use
695 ALCdevice
*volatile next
;
697 /* Memory space used by the default slot (Playback devices only) */
698 alignas(16) ALCbyte _slot_mem
[];
701 // Frequency was requested by the app or config file
702 #define DEVICE_FREQUENCY_REQUEST (1u<<1)
703 // Channel configuration was requested by the config file
704 #define DEVICE_CHANNELS_REQUEST (1u<<2)
705 // Sample type was requested by the config file
706 #define DEVICE_SAMPLE_TYPE_REQUEST (1u<<3)
708 // Specifies if the DSP is paused at user request
709 #define DEVICE_PAUSED (1u<<30)
711 // Specifies if the device is currently running
712 #define DEVICE_RUNNING (1u<<31)
715 /* Nanosecond resolution for the device clock time. */
716 #define DEVICE_CLOCK_RES U64(1000000000)
719 /* Must be less than 15 characters (16 including terminating null) for
720 * compatibility with pthread_setname_np limitations. */
721 #define MIXER_THREAD_NAME "alsoft-mixer"
723 #define RECORD_THREAD_NAME "alsoft-record"
726 struct ALCcontext_struct
{
729 struct ALlistener
*Listener
;
732 UIntMap EffectSlotMap
;
734 ATOMIC(ALenum
) LastError
;
736 enum DistanceModel DistanceModel
;
737 ALboolean SourceDistanceModel
;
739 ALfloat DopplerFactor
;
740 ALfloat DopplerVelocity
;
741 ALfloat SpeedOfSound
;
742 ATOMIC(ALenum
) DeferUpdates
;
746 /* Counter for the pre-mixing updates, in 31.1 fixed point (lowest bit
747 * indicates if updates are currently happening).
749 RefCount UpdateCount
;
750 ATOMIC(ALenum
) HoldUpdates
;
754 struct ALvoice
*Voices
;
758 ATOMIC(struct ALeffectslot
*) ActiveAuxSlotList
;
761 const ALCchar
*ExtensionList
;
763 ALCcontext
*volatile next
;
765 /* Memory space used by the listener */
766 alignas(16) ALCbyte _listener_mem
[];
769 ALCcontext
*GetContextRef(void);
771 void ALCcontext_IncRef(ALCcontext
*context
);
772 void ALCcontext_DecRef(ALCcontext
*context
);
774 void AppendAllDevicesList(const ALCchar
*name
);
775 void AppendCaptureDeviceList(const ALCchar
*name
);
777 void ALCdevice_Lock(ALCdevice
*device
);
778 void ALCdevice_Unlock(ALCdevice
*device
);
780 void ALCcontext_DeferUpdates(ALCcontext
*context
, ALenum type
);
781 void ALCcontext_ProcessUpdates(ALCcontext
*context
);
783 inline void LockContext(ALCcontext
*context
)
784 { ALCdevice_Lock(context
->Device
); }
786 inline void UnlockContext(ALCcontext
*context
)
787 { ALCdevice_Unlock(context
->Device
); }
798 DERIVE_FROM_TYPE(fenv_t
);
806 void SetMixerFPUMode(FPUCtl
*ctl
);
807 void RestoreFPUMode(const FPUCtl
*ctl
);
810 typedef struct ll_ringbuffer ll_ringbuffer_t
;
811 typedef struct ll_ringbuffer_data
{
814 } ll_ringbuffer_data_t
;
815 ll_ringbuffer_t
*ll_ringbuffer_create(size_t sz
, size_t elem_sz
);
816 void ll_ringbuffer_free(ll_ringbuffer_t
*rb
);
817 void ll_ringbuffer_get_read_vector(const ll_ringbuffer_t
*rb
, ll_ringbuffer_data_t
*vec
);
818 void ll_ringbuffer_get_write_vector(const ll_ringbuffer_t
*rb
, ll_ringbuffer_data_t
*vec
);
819 size_t ll_ringbuffer_read(ll_ringbuffer_t
*rb
, char *dest
, size_t cnt
);
820 size_t ll_ringbuffer_peek(ll_ringbuffer_t
*rb
, char *dest
, size_t cnt
);
821 void ll_ringbuffer_read_advance(ll_ringbuffer_t
*rb
, size_t cnt
);
822 size_t ll_ringbuffer_read_space(const ll_ringbuffer_t
*rb
);
823 int ll_ringbuffer_mlock(ll_ringbuffer_t
*rb
);
824 void ll_ringbuffer_reset(ll_ringbuffer_t
*rb
);
825 size_t ll_ringbuffer_write(ll_ringbuffer_t
*rb
, const char *src
, size_t cnt
);
826 void ll_ringbuffer_write_advance(ll_ringbuffer_t
*rb
, size_t cnt
);
827 size_t ll_ringbuffer_write_space(const ll_ringbuffer_t
*rb
);
829 void ReadALConfig(void);
830 void FreeALConfig(void);
831 int ConfigValueExists(const char *devName
, const char *blockName
, const char *keyName
);
832 const char *GetConfigValue(const char *devName
, const char *blockName
, const char *keyName
, const char *def
);
833 int GetConfigValueBool(const char *devName
, const char *blockName
, const char *keyName
, int def
);
834 int ConfigValueStr(const char *devName
, const char *blockName
, const char *keyName
, const char **ret
);
835 int ConfigValueInt(const char *devName
, const char *blockName
, const char *keyName
, int *ret
);
836 int ConfigValueUInt(const char *devName
, const char *blockName
, const char *keyName
, unsigned int *ret
);
837 int ConfigValueFloat(const char *devName
, const char *blockName
, const char *keyName
, float *ret
);
838 int ConfigValueBool(const char *devName
, const char *blockName
, const char *keyName
, int *ret
);
840 void SetRTPriority(void);
842 void SetDefaultChannelOrder(ALCdevice
*device
);
843 void SetDefaultWFXChannelOrder(ALCdevice
*device
);
845 const ALCchar
*DevFmtTypeString(enum DevFmtType type
);
846 const ALCchar
*DevFmtChannelsString(enum DevFmtChannels chans
);
849 * GetChannelIdxByName
851 * Returns the index for the given channel name (e.g. FrontCenter), or -1 if it
854 inline ALint
GetChannelIndex(const enum Channel names
[MAX_OUTPUT_CHANNELS
], enum Channel chan
)
857 for(i
= 0;i
< MAX_OUTPUT_CHANNELS
;i
++)
864 #define GetChannelIdxByName(x, c) GetChannelIndex((x).ChannelName, (c))
866 extern FILE *LogFile
;
868 #if defined(__GNUC__) && !defined(_WIN32) && !defined(IN_IDE_PARSER)
869 #define AL_PRINT(T, MSG, ...) fprintf(LogFile, "AL lib: %s %s: "MSG, T, __FUNCTION__ , ## __VA_ARGS__)
871 void al_print(const char *type
, const char *func
, const char *fmt
, ...) DECL_FORMAT(printf
, 3,4);
872 #define AL_PRINT(T, ...) al_print((T), __FUNCTION__, __VA_ARGS__)
882 extern enum LogLevel LogLevel
;
884 #define TRACEREF(...) do { \
885 if(LogLevel >= LogRef) \
886 AL_PRINT("(--)", __VA_ARGS__); \
889 #define TRACE(...) do { \
890 if(LogLevel >= LogTrace) \
891 AL_PRINT("(II)", __VA_ARGS__); \
894 #define WARN(...) do { \
895 if(LogLevel >= LogWarning) \
896 AL_PRINT("(WW)", __VA_ARGS__); \
899 #define ERR(...) do { \
900 if(LogLevel >= LogError) \
901 AL_PRINT("(EE)", __VA_ARGS__); \
905 extern ALint RTPrioLevel
;
908 extern ALuint CPUCapFlags
;
913 CPU_CAP_SSE4_1
= 1<<3,
917 void FillCPUCaps(ALuint capfilter
);
919 vector_al_string
SearchDataFiles(const char *match
, const char *subdir
);
921 /* Small hack to use a pointer-to-array type as a normal argument type.
922 * Shouldn't be used directly. */
923 typedef ALfloat ALfloatBUFFERSIZE
[BUFFERSIZE
];