16 #define _WIN32_WINNT 0x0500
24 #ifdef HAVE_PTHREAD_NP_H
25 #include <pthread_np.h>
31 #define IsBadWritePtr(a,b) (0)
33 typedef pthread_mutex_t CRITICAL_SECTION
;
34 static inline void EnterCriticalSection(CRITICAL_SECTION
*cs
)
37 ret
= pthread_mutex_lock(cs
);
40 static inline void LeaveCriticalSection(CRITICAL_SECTION
*cs
)
43 ret
= pthread_mutex_unlock(cs
);
46 static inline void InitializeCriticalSection(CRITICAL_SECTION
*cs
)
48 pthread_mutexattr_t attrib
;
51 ret
= pthread_mutexattr_init(&attrib
);
54 ret
= pthread_mutexattr_settype(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
55 #ifdef HAVE_PTHREAD_NP_H
57 ret
= pthread_mutexattr_setkind_np(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
60 ret
= pthread_mutex_init(cs
, &attrib
);
63 pthread_mutexattr_destroy(&attrib
);
66 static inline void DeleteCriticalSection(CRITICAL_SECTION
*cs
)
69 ret
= pthread_mutex_destroy(cs
);
73 /* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
74 * to the expected DWORD. Both are defined as unsigned 32-bit types, however.
75 * Additionally, Win32 is supposed to measure the time since Windows started,
76 * as opposed to the actual time. */
77 static inline ALuint
timeGetTime(void)
82 ret
= gettimeofday(&tv
, NULL
);
85 return tv
.tv_usec
/1000 + tv
.tv_sec
*1000;
88 static inline void Sleep(ALuint t
)
90 struct timespec tv
, rem
;
91 tv
.tv_nsec
= (t
*1000000)%1000000000;
94 while(nanosleep(&tv
, &rem
) == -1 && errno
== EINTR
)
97 #define min(x,y) (((x)<(y))?(x):(y))
98 #define max(x,y) (((x)>(y))?(x):(y))
103 #include "AL/alext.h"
104 #include "alListener.h"
110 extern char _alDebug
[256];
112 #define AL_PRINT(...) do { \
114 const char *_al_print_fn = strrchr(__FILE__, '/'); \
115 if(!_al_print_fn) _al_print_fn = __FILE__; \
116 else _al_print_fn += 1; \
117 _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
118 if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
119 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
120 _alDebug[sizeof(_alDebug)-1] = 0; \
121 fprintf(stderr, "%s", _alDebug); \
125 #define SWMIXER_OUTPUT_RATE 44100
127 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
128 #define AIRABSORBGAINHF (0.994f)
130 #define LOWPASSFREQCUTOFF (5000)
134 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
135 void (*ClosePlayback
)(ALCdevice
*);
137 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
138 void (*CloseCapture
)(ALCdevice
*);
139 void (*StartCapture
)(ALCdevice
*);
140 void (*StopCapture
)(ALCdevice
*);
141 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
142 ALCuint (*AvailableSamples
)(ALCdevice
*);
145 void alc_alsa_init(BackendFuncs
*func_list
);
146 void alc_oss_init(BackendFuncs
*func_list
);
147 void alc_solaris_init(BackendFuncs
*func_list
);
148 void alcDSoundInit(BackendFuncs
*func_list
);
149 void alcWinMMInit(BackendFuncs
*FuncList
);
150 void alc_wave_init(BackendFuncs
*func_list
);
153 struct ALCdevice_struct
155 ALboolean IsCaptureDevice
;
161 ALCchar
*szDeviceName
;
163 // Maximum number of sources that can be created
164 ALuint MaxNoOfSources
;
166 // Context created on this device
170 void *ExtraData
; // For the backend's use
175 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
176 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
177 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
178 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
179 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
180 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
181 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
182 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
184 struct ALCcontext_struct
188 struct ALsource
*Source
;
191 struct ALeffectslot
*AuxiliaryEffectSlot
;
192 ALuint AuxiliaryEffectSlotCount
;
199 ALenum DistanceModel
;
201 ALfloat DopplerFactor
;
202 ALfloat DopplerVelocity
;
203 ALfloat flSpeedOfSound
;
205 ALint lNumMonoSources
;
206 ALint lNumStereoSources
;
209 const ALCchar
*ExtensionList
;
216 ALCvoid
ReleaseALC(ALCvoid
);
218 ALCchar
*AppendDeviceList(char *name
);
219 ALCchar
*AppendAllDeviceList(char *name
);
220 ALCchar
*AppendCaptureDeviceList(char *name
);
222 ALCvoid
SetALCError(ALenum errorCode
);
224 ALCvoid
SuspendContext(ALCcontext
*context
);
225 ALCvoid
ProcessContext(ALCcontext
*context
);
227 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
228 ALuint
StopThread(ALvoid
*thread
);
230 typedef struct RingBuffer RingBuffer
;
231 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
232 void DestroyRingBuffer(RingBuffer
*ring
);
233 ALsizei
RingBufferSize(RingBuffer
*ring
);
234 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
235 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
237 void ReadALConfig(void);
238 void FreeALConfig(void);
239 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
240 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
241 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);