Remove unnecessary function parameters
[openal-soft.git] / OpenAL32 / Include / alMain.h
blobe38233643013a7762baac7d52a877b3fe4c780f5
1 #ifndef AL_MAIN_H
2 #define AL_MAIN_H
4 #include <string.h>
5 #include <stdio.h>
6 #include <stdarg.h>
8 #ifdef HAVE_FENV_H
9 #include <fenv.h>
10 #endif
12 #include "AL/al.h"
13 #include "AL/alc.h"
14 #include "AL/alext.h"
16 #ifdef _WIN32
18 #ifndef _WIN32_WINNT
19 #define _WIN32_WINNT 0x0500
20 #endif
21 #include <windows.h>
23 #else
25 #include <assert.h>
26 #include <pthread.h>
27 #ifdef HAVE_PTHREAD_NP_H
28 #include <pthread_np.h>
29 #endif
30 #include <sys/time.h>
31 #include <time.h>
32 #include <errno.h>
34 #define IsBadWritePtr(a,b) (0)
36 typedef pthread_mutex_t CRITICAL_SECTION;
37 static inline void EnterCriticalSection(CRITICAL_SECTION *cs)
39 int ret;
40 ret = pthread_mutex_lock(cs);
41 assert(ret == 0);
43 static inline void LeaveCriticalSection(CRITICAL_SECTION *cs)
45 int ret;
46 ret = pthread_mutex_unlock(cs);
47 assert(ret == 0);
49 static inline void InitializeCriticalSection(CRITICAL_SECTION *cs)
51 pthread_mutexattr_t attrib;
52 int ret;
54 ret = pthread_mutexattr_init(&attrib);
55 assert(ret == 0);
57 ret = pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE);
58 #ifdef HAVE_PTHREAD_NP_H
59 if(ret != 0)
60 ret = pthread_mutexattr_setkind_np(&attrib, PTHREAD_MUTEX_RECURSIVE);
61 #endif
62 assert(ret == 0);
63 ret = pthread_mutex_init(cs, &attrib);
64 assert(ret == 0);
66 pthread_mutexattr_destroy(&attrib);
69 static inline void DeleteCriticalSection(CRITICAL_SECTION *cs)
71 int ret;
72 ret = pthread_mutex_destroy(cs);
73 assert(ret == 0);
76 /* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
77 * to the expected DWORD. Both are defined as unsigned 32-bit types, however.
78 * Additionally, Win32 is supposed to measure the time since Windows started,
79 * as opposed to the actual time. */
80 static inline ALuint timeGetTime(void)
82 struct timeval tv;
83 int ret;
85 ret = gettimeofday(&tv, NULL);
86 assert(ret == 0);
88 return tv.tv_usec/1000 + tv.tv_sec*1000;
91 static inline void Sleep(ALuint t)
93 struct timespec tv, rem;
94 tv.tv_nsec = (t*1000000)%1000000000;
95 tv.tv_sec = t/1000;
97 while(nanosleep(&tv, &rem) == -1 && errno == EINTR)
98 tv = rem;
100 #define min(x,y) (((x)<(y))?(x):(y))
101 #define max(x,y) (((x)>(y))?(x):(y))
102 #endif
104 #include "alListener.h"
105 #include "alu.h"
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
111 static __inline void al_print(const char *fname, unsigned int line, const char *fmt, ...)
113 const char *fn;
114 char str[256];
115 int i;
117 fn = strrchr(fname, '/');
118 if(!fn) fn = strrchr(fname, '\\');;
119 if(!fn) fn = fname;
120 else fn += 1;
122 i = snprintf(str, sizeof(str), "AL lib: %s:%d: ", fn, line);
123 if(i < (int)sizeof(str) && i > 0)
125 va_list ap;
126 va_start(ap, fmt);
127 vsnprintf(str+i, sizeof(str)-i, fmt, ap);
128 va_end(ap);
130 str[sizeof(str)-1] = 0;
132 fprintf(stderr, "%s", str);
134 #define AL_PRINT(...) al_print(__FILE__, __LINE__, __VA_ARGS__)
137 #define SWMIXER_OUTPUT_RATE 44100
139 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
140 #define AIRABSORBGAINDBHF (-0.05f)
142 #define LOWPASSFREQCUTOFF (5000)
144 #define QUADRANT_NUM 128
145 #define LUT_NUM (4 * QUADRANT_NUM)
148 typedef struct {
149 ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*);
150 void (*ClosePlayback)(ALCdevice*);
151 ALCboolean (*StartContext)(ALCdevice*, ALCcontext*);
152 void (*StopContext)(ALCdevice*, ALCcontext*);
154 ALCboolean (*OpenCapture)(ALCdevice*, const ALCchar*);
155 void (*CloseCapture)(ALCdevice*);
156 void (*StartCapture)(ALCdevice*);
157 void (*StopCapture)(ALCdevice*);
158 void (*CaptureSamples)(ALCdevice*, void*, ALCuint);
159 ALCuint (*AvailableSamples)(ALCdevice*);
160 } BackendFuncs;
162 void alc_alsa_init(BackendFuncs *func_list);
163 void alc_oss_init(BackendFuncs *func_list);
164 void alc_solaris_init(BackendFuncs *func_list);
165 void alcDSoundInit(BackendFuncs *func_list);
166 void alcWinMMInit(BackendFuncs *FuncList);
167 void alc_pa_init(BackendFuncs *func_list);
168 void alc_wave_init(BackendFuncs *func_list);
169 void alc_pulse_init(BackendFuncs *func_list);
172 struct ALCdevice_struct
174 ALboolean IsCaptureDevice;
176 ALuint Frequency;
177 ALuint UpdateSize;
178 ALuint BufferSize;
179 ALenum Format;
181 ALCchar *szDeviceName;
183 // Maximum number of sources that can be created
184 ALuint MaxNoOfSources;
185 // Maximum number of slots that can be created
186 ALuint AuxiliaryEffectSlotMax;
188 ALint lNumMonoSources;
189 ALint lNumStereoSources;
190 ALuint NumAuxSends;
192 // Context created on this device
193 ALCcontext *Context;
195 BackendFuncs *Funcs;
196 void *ExtraData; // For the backend's use
198 ALCdevice *next;
201 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
202 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
203 #define ALCdevice_StartContext(a,b) ((a)->Funcs->StartContext((a), (b)))
204 #define ALCdevice_StopContext(a,b) ((a)->Funcs->StopContext((a), (b)))
205 #define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
206 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
207 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
208 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
209 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
210 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
212 struct ALCcontext_struct
214 ALlistener Listener;
216 struct ALsource *Source;
217 ALuint SourceCount;
219 struct ALeffectslot *AuxiliaryEffectSlot;
220 ALuint AuxiliaryEffectSlotCount;
222 ALenum LastError;
223 ALboolean InUse;
225 ALuint Frequency;
227 ALenum DistanceModel;
229 ALfloat DopplerFactor;
230 ALfloat DopplerVelocity;
231 ALfloat flSpeedOfSound;
233 ALfloat PanningLUT[OUTPUTCHANNELS * LUT_NUM];
234 ALint NumChan;
236 ALfloat ChannelMatrix[OUTPUTCHANNELS][OUTPUTCHANNELS];
238 ALCdevice *Device;
239 const ALCchar *ExtensionList;
241 struct bs2b *bs2b;
243 ALCcontext *next;
246 ALCvoid ReleaseALC(ALCvoid);
248 ALCchar *AppendDeviceList(char *name);
249 ALCchar *AppendAllDeviceList(char *name);
250 ALCchar *AppendCaptureDeviceList(char *name);
252 ALCvoid SetALCError(ALenum errorCode);
254 ALCvoid SuspendContext(ALCcontext *context);
255 ALCvoid ProcessContext(ALCcontext *context);
257 ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
258 ALuint StopThread(ALvoid *thread);
260 typedef struct RingBuffer RingBuffer;
261 RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
262 void DestroyRingBuffer(RingBuffer *ring);
263 ALsizei RingBufferSize(RingBuffer *ring);
264 void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
265 void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
267 void ReadALConfig(void);
268 void FreeALConfig(void);
269 const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
270 int GetConfigValueInt(const char *blockName, const char *keyName, int def);
271 float GetConfigValueFloat(const char *blockName, const char *keyName, float def);
273 #ifdef __cplusplus
275 #endif
277 #endif