Move ALu.c to the Alc directory
[openal-soft.git] / OpenAL32 / Include / alMain.h
blob3d34cf38262fb67f286f2ce74bcec994f9bd35dd
1 #ifndef AL_MAIN_H
2 #define AL_MAIN_H
4 #define AL_MAX_CHANNELS 4
5 #define AL_MAX_SOURCES 32
7 #include <string.h>
9 #include "alu.h"
11 #ifdef _WIN32
12 #include <windows.h>
13 //#define strcasecmp _stricmp
15 #else
17 #include <assert.h>
18 #include <pthread.h>
20 #define IsBadWritePtr(a,b) (0)
22 typedef pthread_mutex_t CRITICAL_SECTION;
23 static inline void EnterCriticalSection(CRITICAL_SECTION *cs)
25 assert(pthread_mutex_lock(cs) == 0);
27 static inline void LeaveCriticalSection(CRITICAL_SECTION *cs)
29 assert(pthread_mutex_unlock(cs) == 0);
31 static inline void InitializeCriticalSection(CRITICAL_SECTION *cs)
33 pthread_mutexattr_t attrib;
35 assert(pthread_mutexattr_init(&attrib) == 0);
37 assert(pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE) == 0);
38 assert(pthread_mutex_init(cs, &attrib) == 0);
40 pthread_mutexattr_destroy(&attrib);
43 static inline void DeleteCriticalSection(CRITICAL_SECTION *cs)
45 assert(pthread_mutex_destroy(cs) == 0);
48 #define min(x,y) (((x)<(y))?(x):(y))
49 #define max(x,y) (((x)>(y))?(x):(y))
50 #endif
52 #include "alBuffer.h"
53 #include "alError.h"
54 #include "alExtension.h"
55 #include "alListener.h"
56 #include "alSource.h"
57 #include "alState.h"
58 #include "alThunk.h"
60 #ifdef __cplusplus
61 extern "C"
63 #endif
65 #define AL_FORMAT_MONO_IMA4 0x1300
66 #define AL_FORMAT_STEREO_IMA4 0x1301
67 // These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer
68 // can use 4-channel formats
69 #define AL_FORMAT_QUAD8 0x1204
70 #define AL_FORMAT_QUAD16 0x1205
72 #define SWMIXER_OUTPUT_RATE 44100
73 //#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050)
75 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
77 typedef struct {
78 ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*);
79 void (*ClosePlayback)(ALCdevice*);
81 ALCboolean (*OpenCapture)(ALCdevice*, const ALCchar*, ALCuint, ALCenum, ALCsizei);
82 void (*CloseCapture)(ALCdevice*);
83 void (*StartCapture)(ALCdevice*);
84 void (*StopCapture)(ALCdevice*);
85 void (*CaptureSamples)(ALCdevice*, void*, ALCuint);
86 ALCuint (*AvailableSamples)(ALCdevice*);
87 } BackendFuncs;
89 struct ALCdevice_struct
91 ALboolean InUse;
92 ALboolean IsCaptureDevice;
94 ALuint Frequency;
95 ALuint UpdateFreq;
96 ALuint FrameSize;
97 ALuint Channels;
98 ALenum Format;
100 ALCchar szDeviceName[256];
102 // Maximum number of sources that can be created
103 ALuint MaxNoOfSources;
105 // Context created on this device
106 ALCcontext *Context;
108 BackendFuncs *Funcs;
109 void *ExtraData; // For the backend's use
112 #define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
113 #define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
114 #define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
115 #define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
116 #define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
117 #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
118 #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c)))
119 #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a)))
121 struct ALCcontext_struct
123 ALlistener Listener;
125 ALsource *Source;
126 ALuint SourceCount;
128 ALenum LastError;
129 ALboolean InUse;
131 ALuint Frequency;
133 ALenum DistanceModel;
135 ALfloat DopplerFactor;
136 ALfloat DopplerVelocity;
137 ALfloat flSpeedOfSound;
139 ALint lNumMonoSources;
140 ALint lNumStereoSources;
142 ALCdevice *Device;
143 ALCchar ExtensionList[1024];
145 ALCcontext *next;
148 ALCchar *AppendDeviceList(char *name);
149 ALCchar *AppendAllDeviceList(char *name);
150 ALCchar *AppendCaptureDeviceList(char *name);
152 ALCvoid SetALCError(ALenum errorCode);
154 ALCvoid SuspendContext(ALCcontext *context);
155 ALCvoid ProcessContext(ALCcontext *context);
157 ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
158 ALuint StopThread(ALvoid *thread);
160 void ReadALConfig(void);
161 void FreeALConfig(void);
162 const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
163 int GetConfigValueInt(const char *blockName, const char *keyName, int def);
164 float GetConfigValueFloat(const char *blockName, const char *keyName, float def);
166 #ifdef __cplusplus
168 #endif
170 #endif