4 #define AL_MAX_CHANNELS 4
5 #define AL_MAX_SOURCES 32
13 //#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 #define min(x,y) (((x)<(y))?(x):(y))
59 #define max(x,y) (((x)>(y))?(x):(y))
64 #include "alExtension.h"
65 #include "alListener.h"
75 extern CRITICAL_SECTION _alMutex
;
77 extern char _alDebug
[256];
79 #define AL_PRINT(...) do { \
81 char *_al_print_fn = strrchr(__FILE__, '/'); \
82 if(!_al_print_fn) _al_print_fn = __FILE__; \
83 else _al_print_fn += 1; \
84 _al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
85 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
86 fprintf(stderr, "%s", _alDebug); \
90 #define AL_FORMAT_MONO_IMA4 0x1300
91 #define AL_FORMAT_STEREO_IMA4 0x1301
92 // These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer
93 // can use 4-channel formats
94 #define AL_FORMAT_QUAD8 0x1204
95 #define AL_FORMAT_QUAD16 0x1205
97 #define SWMIXER_OUTPUT_RATE 44100
98 //#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050)
100 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
101 #define AIRABSORBGAINHF (0.994f)
104 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
105 void (*ClosePlayback
)(ALCdevice
*);
107 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
108 void (*CloseCapture
)(ALCdevice
*);
109 void (*StartCapture
)(ALCdevice
*);
110 void (*StopCapture
)(ALCdevice
*);
111 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
112 ALCuint (*AvailableSamples
)(ALCdevice
*);
115 void alc_alsa_init(BackendFuncs
*func_list
);
116 void alc_oss_init(BackendFuncs
*func_list
);
117 void alcDSoundInit(BackendFuncs
*func_list
);
118 void alcWinMMInit(BackendFuncs
*FuncList
);
121 struct ALCdevice_struct
124 ALboolean IsCaptureDevice
;
132 ALCchar
*szDeviceName
;
134 // Maximum number of sources that can be created
135 ALuint MaxNoOfSources
;
137 // Context created on this device
141 void *ExtraData
; // For the backend's use
144 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
145 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
146 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
147 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
148 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
149 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
150 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
151 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
153 struct ALCcontext_struct
165 ALenum DistanceModel
;
167 ALfloat DopplerFactor
;
168 ALfloat DopplerVelocity
;
169 ALfloat flSpeedOfSound
;
171 ALint lNumMonoSources
;
172 ALint lNumStereoSources
;
175 ALCchar ExtensionList
[1024];
180 ALCchar
*AppendDeviceList(char *name
);
181 ALCchar
*AppendAllDeviceList(char *name
);
182 ALCchar
*AppendCaptureDeviceList(char *name
);
184 ALCvoid
SetALCError(ALenum errorCode
);
186 ALCvoid
SuspendContext(ALCcontext
*context
);
187 ALCvoid
ProcessContext(ALCcontext
*context
);
189 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
190 ALuint
StopThread(ALvoid
*thread
);
192 typedef struct RingBuffer RingBuffer
;
193 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
194 void DestroyRingBuffer(RingBuffer
*ring
);
195 ALsizei
RingBufferSize(RingBuffer
*ring
);
196 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
197 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
199 void ReadALConfig(void);
200 void FreeALConfig(void);
201 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
202 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
203 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);