21 #define IsBadWritePtr(a,b) (0)
23 typedef pthread_mutex_t CRITICAL_SECTION
;
24 static inline void EnterCriticalSection(CRITICAL_SECTION
*cs
)
27 ret
= pthread_mutex_lock(cs
);
30 static inline void LeaveCriticalSection(CRITICAL_SECTION
*cs
)
33 ret
= pthread_mutex_unlock(cs
);
36 static inline void InitializeCriticalSection(CRITICAL_SECTION
*cs
)
38 pthread_mutexattr_t attrib
;
41 ret
= pthread_mutexattr_init(&attrib
);
44 ret
= pthread_mutexattr_settype(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
46 ret
= pthread_mutex_init(cs
, &attrib
);
49 pthread_mutexattr_destroy(&attrib
);
52 static inline void DeleteCriticalSection(CRITICAL_SECTION
*cs
)
55 ret
= pthread_mutex_destroy(cs
);
59 /* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
60 * to the expected DWORD. Both are defined as unsigned 32-bit types, however.
61 * Additionally, Win32 is supposed to measure the time since Windows started,
62 * as opposed to the actual time. */
63 static inline ALuint
timeGetTime(void)
68 ret
= gettimeofday(&tv
, NULL
);
71 return tv
.tv_usec
/1000 + tv
.tv_sec
*1000;
74 static inline void Sleep(ALuint t
)
76 struct timespec tv
, rem
;
77 tv
.tv_nsec
= (t
*1000000)%1000000000;
80 while(nanosleep(&tv
, &rem
) == -1 && errno
== EINTR
)
83 #define min(x,y) (((x)<(y))?(x):(y))
84 #define max(x,y) (((x)>(y))?(x):(y))
90 #include "alListener.h"
96 extern CRITICAL_SECTION _alMutex
;
98 extern char _alDebug
[256];
100 #define AL_PRINT(...) do { \
102 char *_al_print_fn = strrchr(__FILE__, '/'); \
103 if(!_al_print_fn) _al_print_fn = __FILE__; \
104 else _al_print_fn += 1; \
105 _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
106 if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
107 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
108 _alDebug[sizeof(_alDebug)-1] = 0; \
109 fprintf(stderr, "%s", _alDebug); \
113 #define SWMIXER_OUTPUT_RATE 44100
115 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
116 #define AIRABSORBGAINHF (0.994f)
119 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
120 void (*ClosePlayback
)(ALCdevice
*);
122 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
123 void (*CloseCapture
)(ALCdevice
*);
124 void (*StartCapture
)(ALCdevice
*);
125 void (*StopCapture
)(ALCdevice
*);
126 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
127 ALCuint (*AvailableSamples
)(ALCdevice
*);
130 void alc_alsa_init(BackendFuncs
*func_list
);
131 void alc_oss_init(BackendFuncs
*func_list
);
132 void alcDSoundInit(BackendFuncs
*func_list
);
133 void alcWinMMInit(BackendFuncs
*FuncList
);
134 void alc_wave_init(BackendFuncs
*func_list
);
137 struct ALCdevice_struct
139 ALboolean IsCaptureDevice
;
146 ALCchar
*szDeviceName
;
148 // Maximum number of sources that can be created
149 ALuint MaxNoOfSources
;
151 // Context created on this device
155 void *ExtraData
; // For the backend's use
160 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
161 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
162 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
163 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
164 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
165 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
166 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
167 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
169 struct ALCcontext_struct
173 struct ALsource
*Source
;
176 struct ALeffectslot
*AuxiliaryEffectSlot
;
177 ALuint AuxiliaryEffectSlotCount
;
184 ALenum DistanceModel
;
186 ALfloat DopplerFactor
;
187 ALfloat DopplerVelocity
;
188 ALfloat flSpeedOfSound
;
190 ALint lNumMonoSources
;
191 ALint lNumStereoSources
;
194 ALCchar ExtensionList
[1024];
201 ALCvoid
ReleaseALC(ALCvoid
);
203 ALCchar
*AppendDeviceList(char *name
);
204 ALCchar
*AppendAllDeviceList(char *name
);
205 ALCchar
*AppendCaptureDeviceList(char *name
);
207 ALCvoid
SetALCError(ALenum errorCode
);
209 ALCvoid
SuspendContext(ALCcontext
*context
);
210 ALCvoid
ProcessContext(ALCcontext
*context
);
212 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
213 ALuint
StopThread(ALvoid
*thread
);
215 typedef struct RingBuffer RingBuffer
;
216 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
217 void DestroyRingBuffer(RingBuffer
*ring
);
218 ALsizei
RingBufferSize(RingBuffer
*ring
);
219 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
220 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
222 void ReadALConfig(void);
223 void FreeALConfig(void);
224 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
225 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
226 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);