PATH_MAX not MAX_PATH
[openal-soft.git] / router / router.h
blob32a91dcbd0632629ff5b01d9e58f3e1838438a89
1 #ifndef ROUTER_ROUTER_H
2 #define ROUTER_ROUTER_H
4 #define WIN32_LEAN_AND_MEAN
5 #include <windows.h>
6 #include <winnt.h>
8 #include <stdio.h>
10 #include "AL/alc.h"
11 #include "AL/al.h"
12 #include "AL/alext.h"
13 #include "atomic.h"
14 #include "rwlock.h"
15 #include "threads.h"
18 #ifndef UNUSED
19 #if defined(__cplusplus)
20 #define UNUSED(x)
21 #elif defined(__GNUC__)
22 #define UNUSED(x) UNUSED_##x __attribute__((unused))
23 #elif defined(__LCLINT__)
24 #define UNUSED(x) /*@unused@*/ x
25 #else
26 #define UNUSED(x) x
27 #endif
28 #endif
30 #define MAKE_ALC_VER(major, minor) (((major)<<8) | (minor))
32 typedef struct DriverIface {
33 WCHAR Name[32];
34 HMODULE Module;
35 int ALCVer;
37 LPALCCREATECONTEXT alcCreateContext;
38 LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
39 LPALCPROCESSCONTEXT alcProcessContext;
40 LPALCSUSPENDCONTEXT alcSuspendContext;
41 LPALCDESTROYCONTEXT alcDestroyContext;
42 LPALCGETCURRENTCONTEXT alcGetCurrentContext;
43 LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
44 LPALCOPENDEVICE alcOpenDevice;
45 LPALCCLOSEDEVICE alcCloseDevice;
46 LPALCGETERROR alcGetError;
47 LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
48 LPALCGETPROCADDRESS alcGetProcAddress;
49 LPALCGETENUMVALUE alcGetEnumValue;
50 LPALCGETSTRING alcGetString;
51 LPALCGETINTEGERV alcGetIntegerv;
52 LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice;
53 LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice;
54 LPALCCAPTURESTART alcCaptureStart;
55 LPALCCAPTURESTOP alcCaptureStop;
56 LPALCCAPTURESAMPLES alcCaptureSamples;
58 PFNALCSETTHREADCONTEXTPROC alcSetThreadContext;
59 PFNALCGETTHREADCONTEXTPROC alcGetThreadContext;
61 LPALENABLE alEnable;
62 LPALDISABLE alDisable;
63 LPALISENABLED alIsEnabled;
64 LPALGETSTRING alGetString;
65 LPALGETBOOLEANV alGetBooleanv;
66 LPALGETINTEGERV alGetIntegerv;
67 LPALGETFLOATV alGetFloatv;
68 LPALGETDOUBLEV alGetDoublev;
69 LPALGETBOOLEAN alGetBoolean;
70 LPALGETINTEGER alGetInteger;
71 LPALGETFLOAT alGetFloat;
72 LPALGETDOUBLE alGetDouble;
73 LPALGETERROR alGetError;
74 LPALISEXTENSIONPRESENT alIsExtensionPresent;
75 LPALGETPROCADDRESS alGetProcAddress;
76 LPALGETENUMVALUE alGetEnumValue;
77 LPALLISTENERF alListenerf;
78 LPALLISTENER3F alListener3f;
79 LPALLISTENERFV alListenerfv;
80 LPALLISTENERI alListeneri;
81 LPALLISTENER3I alListener3i;
82 LPALLISTENERIV alListeneriv;
83 LPALGETLISTENERF alGetListenerf;
84 LPALGETLISTENER3F alGetListener3f;
85 LPALGETLISTENERFV alGetListenerfv;
86 LPALGETLISTENERI alGetListeneri;
87 LPALGETLISTENER3I alGetListener3i;
88 LPALGETLISTENERIV alGetListeneriv;
89 LPALGENSOURCES alGenSources;
90 LPALDELETESOURCES alDeleteSources;
91 LPALISSOURCE alIsSource;
92 LPALSOURCEF alSourcef;
93 LPALSOURCE3F alSource3f;
94 LPALSOURCEFV alSourcefv;
95 LPALSOURCEI alSourcei;
96 LPALSOURCE3I alSource3i;
97 LPALSOURCEIV alSourceiv;
98 LPALGETSOURCEF alGetSourcef;
99 LPALGETSOURCE3F alGetSource3f;
100 LPALGETSOURCEFV alGetSourcefv;
101 LPALGETSOURCEI alGetSourcei;
102 LPALGETSOURCE3I alGetSource3i;
103 LPALGETSOURCEIV alGetSourceiv;
104 LPALSOURCEPLAYV alSourcePlayv;
105 LPALSOURCESTOPV alSourceStopv;
106 LPALSOURCEREWINDV alSourceRewindv;
107 LPALSOURCEPAUSEV alSourcePausev;
108 LPALSOURCEPLAY alSourcePlay;
109 LPALSOURCESTOP alSourceStop;
110 LPALSOURCEREWIND alSourceRewind;
111 LPALSOURCEPAUSE alSourcePause;
112 LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
113 LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
114 LPALGENBUFFERS alGenBuffers;
115 LPALDELETEBUFFERS alDeleteBuffers;
116 LPALISBUFFER alIsBuffer;
117 LPALBUFFERF alBufferf;
118 LPALBUFFER3F alBuffer3f;
119 LPALBUFFERFV alBufferfv;
120 LPALBUFFERI alBufferi;
121 LPALBUFFER3I alBuffer3i;
122 LPALBUFFERIV alBufferiv;
123 LPALGETBUFFERF alGetBufferf;
124 LPALGETBUFFER3F alGetBuffer3f;
125 LPALGETBUFFERFV alGetBufferfv;
126 LPALGETBUFFERI alGetBufferi;
127 LPALGETBUFFER3I alGetBuffer3i;
128 LPALGETBUFFERIV alGetBufferiv;
129 LPALBUFFERDATA alBufferData;
130 LPALDOPPLERFACTOR alDopplerFactor;
131 LPALDOPPLERVELOCITY alDopplerVelocity;
132 LPALSPEEDOFSOUND alSpeedOfSound;
133 LPALDISTANCEMODEL alDistanceModel;
134 } DriverIface;
136 extern DriverIface *DriverList;
137 extern int DriverListSize;
139 extern altss_t ThreadCtxDriver;
140 typedef ATOMIC(DriverIface*) atomic_DriverIfacePtr;
141 extern atomic_DriverIfacePtr CurrentCtxDriver;
144 typedef struct PtrIntMap {
145 ALvoid **keys;
146 /* Shares memory with keys. */
147 ALint *values;
149 ALsizei size;
150 ALsizei capacity;
151 RWLock lock;
152 } PtrIntMap;
153 #define PTRINTMAP_STATIC_INITIALIZE { NULL, NULL, 0, 0, RWLOCK_STATIC_INITIALIZE }
155 void InitPtrIntMap(PtrIntMap *map);
156 void ResetPtrIntMap(PtrIntMap *map);
157 ALenum InsertPtrIntMapEntry(PtrIntMap *map, ALvoid *key, ALint value);
158 ALint RemovePtrIntMapKey(PtrIntMap *map, ALvoid *key);
159 ALint LookupPtrIntMapKey(PtrIntMap *map, ALvoid *key);
162 void InitALC(void);
163 void ReleaseALC(void);
166 enum LogLevel {
167 LogLevel_None = 0,
168 LogLevel_Error = 1,
169 LogLevel_Warn = 2,
170 LogLevel_Trace = 3,
172 extern enum LogLevel LogLevel;
173 extern FILE *LogFile;
175 #define TRACE(...) do { \
176 if(LogLevel >= LogLevel_Trace) \
178 fprintf(LogFile, "AL Router (II): " __VA_ARGS__); \
179 fflush(LogFile); \
181 } while(0)
182 #define WARN(...) do { \
183 if(LogLevel >= LogLevel_Warn) \
185 fprintf(LogFile, "AL Router (WW): " __VA_ARGS__); \
186 fflush(LogFile); \
188 } while(0)
189 #define ERR(...) do { \
190 if(LogLevel >= LogLevel_Error) \
192 fprintf(LogFile, "AL Router (EE): " __VA_ARGS__); \
193 fflush(LogFile); \
195 } while(0)
197 #endif /* ROUTER_ROUTER_H */