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 if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
86 snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
87 _alDebug[sizeof(_alDebug)-1] = 0; \
88 fprintf(stderr, "%s", _alDebug); \
92 #define AL_FORMAT_MONO_IMA4 0x1300
93 #define AL_FORMAT_STEREO_IMA4 0x1301
94 // These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer
95 // can use the extra formats
96 #define AL_FORMAT_QUAD8 0x1204
97 #define AL_FORMAT_QUAD16 0x1205
98 #define AL_FORMAT_51CHN8 0x120A
99 #define AL_FORMAT_51CHN16 0x120B
101 #define SWMIXER_OUTPUT_RATE 44100
102 //#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050)
104 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
107 ALCboolean (*OpenPlayback
)(ALCdevice
*, const ALCchar
*);
108 void (*ClosePlayback
)(ALCdevice
*);
110 ALCboolean (*OpenCapture
)(ALCdevice
*, const ALCchar
*, ALCuint
, ALCenum
, ALCsizei
);
111 void (*CloseCapture
)(ALCdevice
*);
112 void (*StartCapture
)(ALCdevice
*);
113 void (*StopCapture
)(ALCdevice
*);
114 void (*CaptureSamples
)(ALCdevice
*, void*, ALCuint
);
115 ALCuint (*AvailableSamples
)(ALCdevice
*);
118 void alc_alsa_init(BackendFuncs
*func_list
);
119 void alc_oss_init(BackendFuncs
*func_list
);
120 void alcDSoundInit(BackendFuncs
*func_list
);
121 void alcWinMMInit(BackendFuncs
*FuncList
);
124 struct ALCdevice_struct
127 ALboolean IsCaptureDevice
;
135 ALCchar
*szDeviceName
;
137 // Maximum number of sources that can be created
138 ALuint MaxNoOfSources
;
140 // Context created on this device
144 void *ExtraData
; // For the backend's use
147 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
148 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
149 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
150 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
151 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
152 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
153 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
154 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
156 struct ALCcontext_struct
168 ALenum DistanceModel
;
170 ALfloat DopplerFactor
;
171 ALfloat DopplerVelocity
;
172 ALfloat flSpeedOfSound
;
174 ALint lNumMonoSources
;
175 ALint lNumStereoSources
;
178 ALCchar ExtensionList
[1024];
183 ALCchar
*AppendDeviceList(char *name
);
184 ALCchar
*AppendAllDeviceList(char *name
);
185 ALCchar
*AppendCaptureDeviceList(char *name
);
187 ALCvoid
SetALCError(ALenum errorCode
);
189 ALCvoid
SuspendContext(ALCcontext
*context
);
190 ALCvoid
ProcessContext(ALCcontext
*context
);
192 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
);
193 ALuint
StopThread(ALvoid
*thread
);
195 typedef struct RingBuffer RingBuffer
;
196 RingBuffer
*CreateRingBuffer(ALsizei frame_size
, ALsizei length
);
197 void DestroyRingBuffer(RingBuffer
*ring
);
198 ALsizei
RingBufferSize(RingBuffer
*ring
);
199 void WriteRingBuffer(RingBuffer
*ring
, const ALubyte
*data
, ALsizei len
);
200 void ReadRingBuffer(RingBuffer
*ring
, ALubyte
*data
, ALsizei len
);
202 void ReadALConfig(void);
203 void FreeALConfig(void);
204 const char *GetConfigValue(const char *blockName
, const char *keyName
, const char *def
);
205 int GetConfigValueInt(const char *blockName
, const char *keyName
, int def
);
206 float GetConfigValueFloat(const char *blockName
, const char *keyName
, float def
);