12 #define _WIN32_WINNT 0x0500
24 #define IsBadWritePtr(a,b) (0)
26 typedef pthread_mutex_t CRITICAL_SECTION
;
27 static inline void EnterCriticalSection(CRITICAL_SECTION
*cs
)
30 ret
= pthread_mutex_lock(cs
);
33 static inline void LeaveCriticalSection(CRITICAL_SECTION
*cs
)
36 ret
= pthread_mutex_unlock(cs
);
39 static inline void InitializeCriticalSection(CRITICAL_SECTION
*cs
)
41 pthread_mutexattr_t attrib
;
44 ret
= pthread_mutexattr_init(&attrib
);
47 ret
= pthread_mutexattr_settype(&attrib
, PTHREAD_MUTEX_RECURSIVE
);
49 ret
= pthread_mutex_init(cs
, &attrib
);
52 pthread_mutexattr_destroy(&attrib
);
55 static inline void DeleteCriticalSection(CRITICAL_SECTION
*cs
)
58 ret
= pthread_mutex_destroy(cs
);
62 /* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
63 * to the expected DWORD. Both are defined as unsigned 32-bit types, however.
64 * Additionally, Win32 is supposed to measure the time since Windows started,
65 * as opposed to the actual time. */
66 static inline ALuint
timeGetTime(void)
71 ret
= gettimeofday(&tv
, NULL
);
74 return tv
.tv_usec
/1000 + tv
.tv_sec
*1000;
77 static inline void Sleep(ALuint t
)
79 struct timespec tv
, rem
;
80 tv
.tv_nsec
= (t
*1000000)%1000000000;
83 while(nanosleep(&tv
, &rem
) == -1 && errno
== EINTR
)
86 #define min(x,y) (((x)<(y))?(x):(y))
87 #define max(x,y) (((x)>(y))?(x):(y))
93 #include "alListener.h"
99 extern CRITICAL_SECTION _alMutex
;
101 extern char _alDebug
[256];
103 #define AL_PRINT(...) do { \
105 const char *_al_print_fn = strrchr(__FILE__, '/'); \
106 if(!_al_print_fn) _al_print_fn = __FILE__; \
107 else _al_print_fn += 1; \
108 _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
109 if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
110 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
111 _alDebug[sizeof(_alDebug)-1] = 0; \
112 fprintf(stderr, "%s", _alDebug); \
116 #define SWMIXER_OUTPUT_RATE 44100
118 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
119 #define AIRABSORBGAINHF (0.994f)
122 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
123 void (*ClosePlayback
)(ALCdevice
*);
125 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
126 void (*CloseCapture
)(ALCdevice
*);
127 void (*StartCapture
)(ALCdevice
*);
128 void (*StopCapture
)(ALCdevice
*);
129 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
130 ALCuint (*AvailableSamples
)(ALCdevice
*);
133 void alc_alsa_init(BackendFuncs
*func_list
);
134 void alc_oss_init(BackendFuncs
*func_list
);
135 void alcDSoundInit(BackendFuncs
*func_list
);
136 void alcWinMMInit(BackendFuncs
*FuncList
);
137 void alc_wave_init(BackendFuncs
*func_list
);
140 struct ALCdevice_struct
142 ALboolean IsCaptureDevice
;
148 ALCchar
*szDeviceName
;
150 // Maximum number of sources that can be created
151 ALuint MaxNoOfSources
;
153 // Context created on this device
157 void *ExtraData
; // For the backend's use
162 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
163 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
164 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
165 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
166 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
167 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
168 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
169 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
171 struct ALCcontext_struct
175 struct ALsource
*Source
;
178 struct ALeffectslot
*AuxiliaryEffectSlot
;
179 ALuint AuxiliaryEffectSlotCount
;
186 ALenum DistanceModel
;
188 ALfloat DopplerFactor
;
189 ALfloat DopplerVelocity
;
190 ALfloat flSpeedOfSound
;
192 ALint lNumMonoSources
;
193 ALint lNumStereoSources
;
196 ALCchar ExtensionList
[1024];
203 ALCvoid
ReleaseALC(ALCvoid
);
205 ALCchar
*AppendDeviceList(char *name
);
206 ALCchar
*AppendAllDeviceList(char *name
);
207 ALCchar
*AppendCaptureDeviceList(char *name
);
209 ALCvoid
SetALCError(ALenum errorCode
);
211 ALCvoid
SuspendContext(ALCcontext
*context
);
212 ALCvoid
ProcessContext(ALCcontext
*context
);
214 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
215 ALuint
StopThread(ALvoid
*thread
);
217 typedef struct RingBuffer RingBuffer
;
218 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
219 void DestroyRingBuffer(RingBuffer
*ring
);
220 ALsizei
RingBufferSize(RingBuffer
*ring
);
221 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
222 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
224 void ReadALConfig(void);
225 void FreeALConfig(void);
226 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
227 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
228 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);