12 #define _WIN32_WINNT 0x0500
20 #ifdef HAVE_PTHREAD_NP_H
21 #include <pthread_np.h>
27 #define IsBadWritePtr(a,b) (0)
29 typedef pthread_mutex_t CRITICAL_SECTION
;
30 static inline void EnterCriticalSection(CRITICAL_SECTION
*cs
)
33 ret
= pthread_mutex_lock(cs
);
36 static inline void LeaveCriticalSection(CRITICAL_SECTION
*cs
)
39 ret
= pthread_mutex_unlock(cs
);
42 static inline void InitializeCriticalSection(CRITICAL_SECTION
*cs
)
44 pthread_mutexattr_t attrib
;
47 ret
= pthread_mutexattr_init(&attrib
);
50 ret
= pthread_mutexattr_settype(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
51 #ifdef HAVE_PTHREAD_NP_H
53 ret
= pthread_mutexattr_setkind_np(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
56 ret
= pthread_mutex_init(cs
, &attrib
);
59 pthread_mutexattr_destroy(&attrib
);
62 static inline void DeleteCriticalSection(CRITICAL_SECTION
*cs
)
65 ret
= pthread_mutex_destroy(cs
);
69 /* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
70 * to the expected DWORD. Both are defined as unsigned 32-bit types, however.
71 * Additionally, Win32 is supposed to measure the time since Windows started,
72 * as opposed to the actual time. */
73 static inline ALuint
timeGetTime(void)
78 ret
= gettimeofday(&tv
, NULL
);
81 return tv
.tv_usec
/1000 + tv
.tv_sec
*1000;
84 static inline void Sleep(ALuint t
)
86 struct timespec tv
, rem
;
87 tv
.tv_nsec
= (t
*1000000)%1000000000;
90 while(nanosleep(&tv
, &rem
) == -1 && errno
== EINTR
)
93 #define min(x,y) (((x)<(y))?(x):(y))
94 #define max(x,y) (((x)>(y))?(x):(y))
100 #include "alListener.h"
106 extern char _alDebug
[256];
108 #define AL_PRINT(...) do { \
110 const char *_al_print_fn = strrchr(__FILE__, '/'); \
111 if(!_al_print_fn) _al_print_fn = __FILE__; \
112 else _al_print_fn += 1; \
113 _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
114 if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
115 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
116 _alDebug[sizeof(_alDebug)-1] = 0; \
117 fprintf(stderr, "%s", _alDebug); \
121 #define SWMIXER_OUTPUT_RATE 44100
123 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
124 #define AIRABSORBGAINHF (0.994f)
127 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
128 void (*ClosePlayback
)(ALCdevice
*);
130 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
131 void (*CloseCapture
)(ALCdevice
*);
132 void (*StartCapture
)(ALCdevice
*);
133 void (*StopCapture
)(ALCdevice
*);
134 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
135 ALCuint (*AvailableSamples
)(ALCdevice
*);
138 void alc_alsa_init(BackendFuncs
*func_list
);
139 void alc_oss_init(BackendFuncs
*func_list
);
140 void alcDSoundInit(BackendFuncs
*func_list
);
141 void alcWinMMInit(BackendFuncs
*FuncList
);
142 void alc_wave_init(BackendFuncs
*func_list
);
145 struct ALCdevice_struct
147 ALboolean IsCaptureDevice
;
153 ALCchar
*szDeviceName
;
155 // Maximum number of sources that can be created
156 ALuint MaxNoOfSources
;
158 // Context created on this device
162 void *ExtraData
; // For the backend's use
167 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
168 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
169 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
170 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
171 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
172 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
173 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
174 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
176 struct ALCcontext_struct
180 struct ALsource
*Source
;
183 struct ALeffectslot
*AuxiliaryEffectSlot
;
184 ALuint AuxiliaryEffectSlotCount
;
191 ALenum DistanceModel
;
193 ALfloat DopplerFactor
;
194 ALfloat DopplerVelocity
;
195 ALfloat flSpeedOfSound
;
197 ALint lNumMonoSources
;
198 ALint lNumStereoSources
;
201 const ALCchar
*ExtensionList
;
208 ALCvoid
ReleaseALC(ALCvoid
);
210 ALCchar
*AppendDeviceList(char *name
);
211 ALCchar
*AppendAllDeviceList(char *name
);
212 ALCchar
*AppendCaptureDeviceList(char *name
);
214 ALCvoid
SetALCError(ALenum errorCode
);
216 ALCvoid
SuspendContext(ALCcontext
*context
);
217 ALCvoid
ProcessContext(ALCcontext
*context
);
219 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
220 ALuint
StopThread(ALvoid
*thread
);
222 typedef struct RingBuffer RingBuffer
;
223 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
224 void DestroyRingBuffer(RingBuffer
*ring
);
225 ALsizei
RingBufferSize(RingBuffer
*ring
);
226 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
227 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
229 void ReadALConfig(void);
230 void FreeALConfig(void);
231 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
232 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
233 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);