Adjust padding in alsoft-config and remove an invalid signal
[openal-soft.git] / router / router.h
blob007b6a16fbd4208834510c12ff6489685c8a2b9f
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 <vector>
11 #include <string>
12 #include <atomic>
13 #include <mutex>
15 #include "AL/alc.h"
16 #include "AL/al.h"
17 #include "AL/alext.h"
20 #define MAKE_ALC_VER(major, minor) (((major)<<8) | (minor))
22 struct DriverIface {
23 std::wstring Name;
24 HMODULE Module{nullptr};
25 int ALCVer{0};
27 LPALCCREATECONTEXT alcCreateContext{nullptr};
28 LPALCMAKECONTEXTCURRENT alcMakeContextCurrent{nullptr};
29 LPALCPROCESSCONTEXT alcProcessContext{nullptr};
30 LPALCSUSPENDCONTEXT alcSuspendContext{nullptr};
31 LPALCDESTROYCONTEXT alcDestroyContext{nullptr};
32 LPALCGETCURRENTCONTEXT alcGetCurrentContext{nullptr};
33 LPALCGETCONTEXTSDEVICE alcGetContextsDevice{nullptr};
34 LPALCOPENDEVICE alcOpenDevice{nullptr};
35 LPALCCLOSEDEVICE alcCloseDevice{nullptr};
36 LPALCGETERROR alcGetError{nullptr};
37 LPALCISEXTENSIONPRESENT alcIsExtensionPresent{nullptr};
38 LPALCGETPROCADDRESS alcGetProcAddress{nullptr};
39 LPALCGETENUMVALUE alcGetEnumValue{nullptr};
40 LPALCGETSTRING alcGetString{nullptr};
41 LPALCGETINTEGERV alcGetIntegerv{nullptr};
42 LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice{nullptr};
43 LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice{nullptr};
44 LPALCCAPTURESTART alcCaptureStart{nullptr};
45 LPALCCAPTURESTOP alcCaptureStop{nullptr};
46 LPALCCAPTURESAMPLES alcCaptureSamples{nullptr};
48 PFNALCSETTHREADCONTEXTPROC alcSetThreadContext{nullptr};
49 PFNALCGETTHREADCONTEXTPROC alcGetThreadContext{nullptr};
51 LPALENABLE alEnable{nullptr};
52 LPALDISABLE alDisable{nullptr};
53 LPALISENABLED alIsEnabled{nullptr};
54 LPALGETSTRING alGetString{nullptr};
55 LPALGETBOOLEANV alGetBooleanv{nullptr};
56 LPALGETINTEGERV alGetIntegerv{nullptr};
57 LPALGETFLOATV alGetFloatv{nullptr};
58 LPALGETDOUBLEV alGetDoublev{nullptr};
59 LPALGETBOOLEAN alGetBoolean{nullptr};
60 LPALGETINTEGER alGetInteger{nullptr};
61 LPALGETFLOAT alGetFloat{nullptr};
62 LPALGETDOUBLE alGetDouble{nullptr};
63 LPALGETERROR alGetError{nullptr};
64 LPALISEXTENSIONPRESENT alIsExtensionPresent{nullptr};
65 LPALGETPROCADDRESS alGetProcAddress{nullptr};
66 LPALGETENUMVALUE alGetEnumValue{nullptr};
67 LPALLISTENERF alListenerf{nullptr};
68 LPALLISTENER3F alListener3f{nullptr};
69 LPALLISTENERFV alListenerfv{nullptr};
70 LPALLISTENERI alListeneri{nullptr};
71 LPALLISTENER3I alListener3i{nullptr};
72 LPALLISTENERIV alListeneriv{nullptr};
73 LPALGETLISTENERF alGetListenerf{nullptr};
74 LPALGETLISTENER3F alGetListener3f{nullptr};
75 LPALGETLISTENERFV alGetListenerfv{nullptr};
76 LPALGETLISTENERI alGetListeneri{nullptr};
77 LPALGETLISTENER3I alGetListener3i{nullptr};
78 LPALGETLISTENERIV alGetListeneriv{nullptr};
79 LPALGENSOURCES alGenSources{nullptr};
80 LPALDELETESOURCES alDeleteSources{nullptr};
81 LPALISSOURCE alIsSource{nullptr};
82 LPALSOURCEF alSourcef{nullptr};
83 LPALSOURCE3F alSource3f{nullptr};
84 LPALSOURCEFV alSourcefv{nullptr};
85 LPALSOURCEI alSourcei{nullptr};
86 LPALSOURCE3I alSource3i{nullptr};
87 LPALSOURCEIV alSourceiv{nullptr};
88 LPALGETSOURCEF alGetSourcef{nullptr};
89 LPALGETSOURCE3F alGetSource3f{nullptr};
90 LPALGETSOURCEFV alGetSourcefv{nullptr};
91 LPALGETSOURCEI alGetSourcei{nullptr};
92 LPALGETSOURCE3I alGetSource3i{nullptr};
93 LPALGETSOURCEIV alGetSourceiv{nullptr};
94 LPALSOURCEPLAYV alSourcePlayv{nullptr};
95 LPALSOURCESTOPV alSourceStopv{nullptr};
96 LPALSOURCEREWINDV alSourceRewindv{nullptr};
97 LPALSOURCEPAUSEV alSourcePausev{nullptr};
98 LPALSOURCEPLAY alSourcePlay{nullptr};
99 LPALSOURCESTOP alSourceStop{nullptr};
100 LPALSOURCEREWIND alSourceRewind{nullptr};
101 LPALSOURCEPAUSE alSourcePause{nullptr};
102 LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers{nullptr};
103 LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers{nullptr};
104 LPALGENBUFFERS alGenBuffers{nullptr};
105 LPALDELETEBUFFERS alDeleteBuffers{nullptr};
106 LPALISBUFFER alIsBuffer{nullptr};
107 LPALBUFFERF alBufferf{nullptr};
108 LPALBUFFER3F alBuffer3f{nullptr};
109 LPALBUFFERFV alBufferfv{nullptr};
110 LPALBUFFERI alBufferi{nullptr};
111 LPALBUFFER3I alBuffer3i{nullptr};
112 LPALBUFFERIV alBufferiv{nullptr};
113 LPALGETBUFFERF alGetBufferf{nullptr};
114 LPALGETBUFFER3F alGetBuffer3f{nullptr};
115 LPALGETBUFFERFV alGetBufferfv{nullptr};
116 LPALGETBUFFERI alGetBufferi{nullptr};
117 LPALGETBUFFER3I alGetBuffer3i{nullptr};
118 LPALGETBUFFERIV alGetBufferiv{nullptr};
119 LPALBUFFERDATA alBufferData{nullptr};
120 LPALDOPPLERFACTOR alDopplerFactor{nullptr};
121 LPALDOPPLERVELOCITY alDopplerVelocity{nullptr};
122 LPALSPEEDOFSOUND alSpeedOfSound{nullptr};
123 LPALDISTANCEMODEL alDistanceModel{nullptr};
125 DriverIface(std::wstring name, HMODULE mod)
126 : Name(std::move(name)), Module(mod)
128 ~DriverIface()
130 if(Module)
131 FreeLibrary(Module);
132 Module = nullptr;
136 extern std::vector<DriverIface> DriverList;
138 extern thread_local DriverIface *ThreadCtxDriver;
139 extern std::atomic<DriverIface*> CurrentCtxDriver;
142 class PtrIntMap {
143 ALvoid **mKeys{nullptr};
144 /* Shares memory with keys. */
145 ALint *mValues{nullptr};
147 ALsizei mSize{0};
148 ALsizei mCapacity{0};
149 std::mutex mLock;
151 public:
152 PtrIntMap() = default;
153 ~PtrIntMap();
155 ALenum insert(ALvoid *key, ALint value);
156 ALint removeByKey(ALvoid *key);
157 ALint lookupByKey(ALvoid *key);
161 enum LogLevel {
162 LogLevel_None = 0,
163 LogLevel_Error = 1,
164 LogLevel_Warn = 2,
165 LogLevel_Trace = 3,
167 extern enum LogLevel LogLevel;
168 extern FILE *LogFile;
170 #define TRACE(...) do { \
171 if(LogLevel >= LogLevel_Trace) \
173 fprintf(LogFile, "AL Router (II): " __VA_ARGS__); \
174 fflush(LogFile); \
176 } while(0)
177 #define WARN(...) do { \
178 if(LogLevel >= LogLevel_Warn) \
180 fprintf(LogFile, "AL Router (WW): " __VA_ARGS__); \
181 fflush(LogFile); \
183 } while(0)
184 #define ERR(...) do { \
185 if(LogLevel >= LogLevel_Error) \
187 fprintf(LogFile, "AL Router (EE): " __VA_ARGS__); \
188 fflush(LogFile); \
190 } while(0)
192 #endif /* ROUTER_ROUTER_H */