10 //#define strcasecmp _stricmp
20 #define IsBadWritePtr(a,b) (0)
22 typedef pthread_mutex_t CRITICAL_SECTION
;
23 static inline void EnterCriticalSection(CRITICAL_SECTION
*cs
)
26 ret
= pthread_mutex_lock(cs
);
29 static inline void LeaveCriticalSection(CRITICAL_SECTION
*cs
)
32 ret
= pthread_mutex_unlock(cs
);
35 static inline void InitializeCriticalSection(CRITICAL_SECTION
*cs
)
37 pthread_mutexattr_t attrib
;
40 ret
= pthread_mutexattr_init(&attrib
);
43 ret
= pthread_mutexattr_settype(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
45 ret
= pthread_mutex_init(cs
, &attrib
);
48 pthread_mutexattr_destroy(&attrib
);
51 static inline void DeleteCriticalSection(CRITICAL_SECTION
*cs
)
54 ret
= pthread_mutex_destroy(cs
);
58 /* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
59 * to the expected DWORD. Both are defined as unsigned 32-bit types, however.
60 * Additionally, Win32 is supposed to measure the time since Windows started,
61 * as opposed to the actual time. */
62 static inline ALuint
timeGetTime(void)
67 ret
= gettimeofday(&tv
, NULL
);
70 return tv
.tv_usec
/1000 + tv
.tv_sec
*1000;
73 static inline void Sleep(ALuint t
)
75 struct timespec tv
, rem
;
76 tv
.tv_nsec
= (t
*1000000)%1000000000;
79 while(nanosleep(&tv
, &rem
) == -1 && errno
== EINTR
)
82 #define min(x,y) (((x)<(y))?(x):(y))
83 #define max(x,y) (((x)>(y))?(x):(y))
86 #include "alListener.h"
93 extern CRITICAL_SECTION _alMutex
;
95 extern char _alDebug
[256];
97 #define AL_PRINT(...) do { \
99 char *_al_print_fn = strrchr(__FILE__, '/'); \
100 if(!_al_print_fn) _al_print_fn = __FILE__; \
101 else _al_print_fn += 1; \
102 _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
103 if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
104 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
105 _alDebug[sizeof(_alDebug)-1] = 0; \
106 fprintf(stderr, "%s", _alDebug); \
110 #define AL_FORMAT_MONO_FLOAT32 0x10010
111 #define AL_FORMAT_STEREO_FLOAT32 0x10011
113 #define AL_FORMAT_MONO_IMA4 0x1300
114 #define AL_FORMAT_STEREO_IMA4 0x1301
116 #define AL_FORMAT_51CHN8 0x120A
117 #define AL_FORMAT_51CHN16 0x120B
118 #define AL_FORMAT_51CHN32 0x120C
119 #define AL_FORMAT_61CHN8 0x120D
120 #define AL_FORMAT_61CHN16 0x120E
121 #define AL_FORMAT_61CHN32 0x120F
122 #define AL_FORMAT_71CHN8 0x1210
123 #define AL_FORMAT_71CHN16 0x1211
124 #define AL_FORMAT_71CHN32 0x1212
125 #define AL_FORMAT_QUAD8 0x1204
126 #define AL_FORMAT_QUAD16 0x1205
127 #define AL_FORMAT_QUAD32 0x1206
128 #define AL_FORMAT_REAR8 0x1207
129 #define AL_FORMAT_REAR16 0x1208
130 #define AL_FORMAT_REAR32 0x1209
132 #define SWMIXER_OUTPUT_RATE 44100
134 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
137 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
138 void (*ClosePlayback
)(ALCdevice
*);
140 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
141 void (*CloseCapture
)(ALCdevice
*);
142 void (*StartCapture
)(ALCdevice
*);
143 void (*StopCapture
)(ALCdevice
*);
144 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
145 ALCuint (*AvailableSamples
)(ALCdevice
*);
148 void alc_alsa_init(BackendFuncs
*func_list
);
149 void alc_oss_init(BackendFuncs
*func_list
);
150 void alcDSoundInit(BackendFuncs
*func_list
);
151 void alcWinMMInit(BackendFuncs
*FuncList
);
154 struct ALCdevice_struct
157 ALboolean IsCaptureDevice
;
165 ALCchar
*szDeviceName
;
167 // Maximum number of sources that can be created
168 ALuint MaxNoOfSources
;
170 // Context created on this device
174 void *ExtraData
; // For the backend's use
177 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
178 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
179 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
180 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
181 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
182 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
183 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
184 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
186 struct ALCcontext_struct
190 struct ALsource
*Source
;
198 ALenum DistanceModel
;
200 ALfloat DopplerFactor
;
201 ALfloat DopplerVelocity
;
202 ALfloat flSpeedOfSound
;
204 ALint lNumMonoSources
;
205 ALint lNumStereoSources
;
208 ALCchar ExtensionList
[1024];
215 ALCchar
*AppendDeviceList(char *name
);
216 ALCchar
*AppendAllDeviceList(char *name
);
217 ALCchar
*AppendCaptureDeviceList(char *name
);
219 ALCvoid
SetALCError(ALenum errorCode
);
221 ALCvoid
SuspendContext(ALCcontext
*context
);
222 ALCvoid
ProcessContext(ALCcontext
*context
);
224 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
225 ALuint
StopThread(ALvoid
*thread
);
227 typedef struct RingBuffer RingBuffer
;
228 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
229 void DestroyRingBuffer(RingBuffer
*ring
);
230 ALsizei
RingBufferSize(RingBuffer
*ring
);
231 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
232 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
234 void ReadALConfig(void);
235 void FreeALConfig(void);
236 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
237 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
238 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);