10 //#define strcasecmp _stricmp
17 #define IsBadWritePtr(a,b) (0)
19 typedef pthread_mutex_t CRITICAL_SECTION
;
20 static inline void EnterCriticalSection(CRITICAL_SECTION
*cs
)
23 ret
= pthread_mutex_lock(cs
);
26 static inline void LeaveCriticalSection(CRITICAL_SECTION
*cs
)
29 ret
= pthread_mutex_unlock(cs
);
32 static inline void InitializeCriticalSection(CRITICAL_SECTION
*cs
)
34 pthread_mutexattr_t attrib
;
37 ret
= pthread_mutexattr_init(&attrib
);
40 ret
= pthread_mutexattr_settype(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
42 ret
= pthread_mutex_init(cs
, &attrib
);
45 pthread_mutexattr_destroy(&attrib
);
48 static inline void DeleteCriticalSection(CRITICAL_SECTION
*cs
)
51 ret
= pthread_mutex_destroy(cs
);
55 #define min(x,y) (((x)<(y))?(x):(y))
56 #define max(x,y) (((x)>(y))?(x):(y))
59 #include "alListener.h"
66 extern CRITICAL_SECTION _alMutex
;
68 extern char _alDebug
[256];
70 #define AL_PRINT(...) do { \
72 char *_al_print_fn = strrchr(__FILE__, '/'); \
73 if(!_al_print_fn) _al_print_fn = __FILE__; \
74 else _al_print_fn += 1; \
75 _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
76 if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
77 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
78 _alDebug[sizeof(_alDebug)-1] = 0; \
79 fprintf(stderr, "%s", _alDebug); \
83 #define AL_FORMAT_MONO_FLOAT32 0x10010
84 #define AL_FORMAT_STEREO_FLOAT32 0x10011
86 #define AL_FORMAT_MONO_IMA4 0x1300
87 #define AL_FORMAT_STEREO_IMA4 0x1301
89 #define AL_FORMAT_51CHN8 0x120A
90 #define AL_FORMAT_51CHN16 0x120B
91 #define AL_FORMAT_51CHN32 0x120C
92 #define AL_FORMAT_61CHN8 0x120D
93 #define AL_FORMAT_61CHN16 0x120E
94 #define AL_FORMAT_61CHN32 0x120F
95 #define AL_FORMAT_71CHN8 0x1210
96 #define AL_FORMAT_71CHN16 0x1211
97 #define AL_FORMAT_71CHN32 0x1212
98 #define AL_FORMAT_QUAD8 0x1204
99 #define AL_FORMAT_QUAD16 0x1205
100 #define AL_FORMAT_QUAD32 0x1206
101 #define AL_FORMAT_REAR8 0x1207
102 #define AL_FORMAT_REAR16 0x1208
103 #define AL_FORMAT_REAR32 0x1209
105 #define SWMIXER_OUTPUT_RATE 44100
107 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
108 #define AIRABSORBGAINHF (0.994f)
111 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
112 void (*ClosePlayback
)(ALCdevice
*);
114 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
115 void (*CloseCapture
)(ALCdevice
*);
116 void (*StartCapture
)(ALCdevice
*);
117 void (*StopCapture
)(ALCdevice
*);
118 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
119 ALCuint (*AvailableSamples
)(ALCdevice
*);
122 void alc_alsa_init(BackendFuncs
*func_list
);
123 void alc_oss_init(BackendFuncs
*func_list
);
124 void alcDSoundInit(BackendFuncs
*func_list
);
125 void alcWinMMInit(BackendFuncs
*FuncList
);
128 struct ALCdevice_struct
131 ALboolean IsCaptureDevice
;
139 ALCchar
*szDeviceName
;
141 // Maximum number of sources that can be created
142 ALuint MaxNoOfSources
;
144 // Context created on this device
148 void *ExtraData
; // For the backend's use
151 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
152 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
153 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
154 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
155 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
156 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
157 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
158 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
160 struct ALCcontext_struct
164 struct ALsource
*Source
;
172 ALenum DistanceModel
;
174 ALfloat DopplerFactor
;
175 ALfloat DopplerVelocity
;
176 ALfloat flSpeedOfSound
;
178 ALint lNumMonoSources
;
179 ALint lNumStereoSources
;
182 ALCchar ExtensionList
[1024];
187 ALCchar
*AppendDeviceList(char *name
);
188 ALCchar
*AppendAllDeviceList(char *name
);
189 ALCchar
*AppendCaptureDeviceList(char *name
);
191 ALCvoid
SetALCError(ALenum errorCode
);
193 ALCvoid
SuspendContext(ALCcontext
*context
);
194 ALCvoid
ProcessContext(ALCcontext
*context
);
196 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
197 ALuint
StopThread(ALvoid
*thread
);
199 typedef struct RingBuffer RingBuffer
;
200 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
201 void DestroyRingBuffer(RingBuffer
*ring
);
202 ALsizei
RingBufferSize(RingBuffer
*ring
);
203 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
204 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
206 void ReadALConfig(void);
207 void FreeALConfig(void);
208 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
209 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
210 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);