1 #ifndef ROUTER_ROUTER_H
2 #define ROUTER_ROUTER_H
4 #define WIN32_LEAN_AND_MEAN
21 #define MAKE_ALC_VER(major, minor) (((major)<<8) | (minor))
25 HMODULE Module
{nullptr};
28 LPALCCREATECONTEXT alcCreateContext
{nullptr};
29 LPALCMAKECONTEXTCURRENT alcMakeContextCurrent
{nullptr};
30 LPALCPROCESSCONTEXT alcProcessContext
{nullptr};
31 LPALCSUSPENDCONTEXT alcSuspendContext
{nullptr};
32 LPALCDESTROYCONTEXT alcDestroyContext
{nullptr};
33 LPALCGETCURRENTCONTEXT alcGetCurrentContext
{nullptr};
34 LPALCGETCONTEXTSDEVICE alcGetContextsDevice
{nullptr};
35 LPALCOPENDEVICE alcOpenDevice
{nullptr};
36 LPALCCLOSEDEVICE alcCloseDevice
{nullptr};
37 LPALCGETERROR alcGetError
{nullptr};
38 LPALCISEXTENSIONPRESENT alcIsExtensionPresent
{nullptr};
39 LPALCGETPROCADDRESS alcGetProcAddress
{nullptr};
40 LPALCGETENUMVALUE alcGetEnumValue
{nullptr};
41 LPALCGETSTRING alcGetString
{nullptr};
42 LPALCGETINTEGERV alcGetIntegerv
{nullptr};
43 LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice
{nullptr};
44 LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice
{nullptr};
45 LPALCCAPTURESTART alcCaptureStart
{nullptr};
46 LPALCCAPTURESTOP alcCaptureStop
{nullptr};
47 LPALCCAPTURESAMPLES alcCaptureSamples
{nullptr};
49 PFNALCSETTHREADCONTEXTPROC alcSetThreadContext
{nullptr};
50 PFNALCGETTHREADCONTEXTPROC alcGetThreadContext
{nullptr};
52 LPALENABLE alEnable
{nullptr};
53 LPALDISABLE alDisable
{nullptr};
54 LPALISENABLED alIsEnabled
{nullptr};
55 LPALGETSTRING alGetString
{nullptr};
56 LPALGETBOOLEANV alGetBooleanv
{nullptr};
57 LPALGETINTEGERV alGetIntegerv
{nullptr};
58 LPALGETFLOATV alGetFloatv
{nullptr};
59 LPALGETDOUBLEV alGetDoublev
{nullptr};
60 LPALGETBOOLEAN alGetBoolean
{nullptr};
61 LPALGETINTEGER alGetInteger
{nullptr};
62 LPALGETFLOAT alGetFloat
{nullptr};
63 LPALGETDOUBLE alGetDouble
{nullptr};
64 LPALGETERROR alGetError
{nullptr};
65 LPALISEXTENSIONPRESENT alIsExtensionPresent
{nullptr};
66 LPALGETPROCADDRESS alGetProcAddress
{nullptr};
67 LPALGETENUMVALUE alGetEnumValue
{nullptr};
68 LPALLISTENERF alListenerf
{nullptr};
69 LPALLISTENER3F alListener3f
{nullptr};
70 LPALLISTENERFV alListenerfv
{nullptr};
71 LPALLISTENERI alListeneri
{nullptr};
72 LPALLISTENER3I alListener3i
{nullptr};
73 LPALLISTENERIV alListeneriv
{nullptr};
74 LPALGETLISTENERF alGetListenerf
{nullptr};
75 LPALGETLISTENER3F alGetListener3f
{nullptr};
76 LPALGETLISTENERFV alGetListenerfv
{nullptr};
77 LPALGETLISTENERI alGetListeneri
{nullptr};
78 LPALGETLISTENER3I alGetListener3i
{nullptr};
79 LPALGETLISTENERIV alGetListeneriv
{nullptr};
80 LPALGENSOURCES alGenSources
{nullptr};
81 LPALDELETESOURCES alDeleteSources
{nullptr};
82 LPALISSOURCE alIsSource
{nullptr};
83 LPALSOURCEF alSourcef
{nullptr};
84 LPALSOURCE3F alSource3f
{nullptr};
85 LPALSOURCEFV alSourcefv
{nullptr};
86 LPALSOURCEI alSourcei
{nullptr};
87 LPALSOURCE3I alSource3i
{nullptr};
88 LPALSOURCEIV alSourceiv
{nullptr};
89 LPALGETSOURCEF alGetSourcef
{nullptr};
90 LPALGETSOURCE3F alGetSource3f
{nullptr};
91 LPALGETSOURCEFV alGetSourcefv
{nullptr};
92 LPALGETSOURCEI alGetSourcei
{nullptr};
93 LPALGETSOURCE3I alGetSource3i
{nullptr};
94 LPALGETSOURCEIV alGetSourceiv
{nullptr};
95 LPALSOURCEPLAYV alSourcePlayv
{nullptr};
96 LPALSOURCESTOPV alSourceStopv
{nullptr};
97 LPALSOURCEREWINDV alSourceRewindv
{nullptr};
98 LPALSOURCEPAUSEV alSourcePausev
{nullptr};
99 LPALSOURCEPLAY alSourcePlay
{nullptr};
100 LPALSOURCESTOP alSourceStop
{nullptr};
101 LPALSOURCEREWIND alSourceRewind
{nullptr};
102 LPALSOURCEPAUSE alSourcePause
{nullptr};
103 LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers
{nullptr};
104 LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers
{nullptr};
105 LPALGENBUFFERS alGenBuffers
{nullptr};
106 LPALDELETEBUFFERS alDeleteBuffers
{nullptr};
107 LPALISBUFFER alIsBuffer
{nullptr};
108 LPALBUFFERF alBufferf
{nullptr};
109 LPALBUFFER3F alBuffer3f
{nullptr};
110 LPALBUFFERFV alBufferfv
{nullptr};
111 LPALBUFFERI alBufferi
{nullptr};
112 LPALBUFFER3I alBuffer3i
{nullptr};
113 LPALBUFFERIV alBufferiv
{nullptr};
114 LPALGETBUFFERF alGetBufferf
{nullptr};
115 LPALGETBUFFER3F alGetBuffer3f
{nullptr};
116 LPALGETBUFFERFV alGetBufferfv
{nullptr};
117 LPALGETBUFFERI alGetBufferi
{nullptr};
118 LPALGETBUFFER3I alGetBuffer3i
{nullptr};
119 LPALGETBUFFERIV alGetBufferiv
{nullptr};
120 LPALBUFFERDATA alBufferData
{nullptr};
121 LPALDOPPLERFACTOR alDopplerFactor
{nullptr};
122 LPALDOPPLERVELOCITY alDopplerVelocity
{nullptr};
123 LPALSPEEDOFSOUND alSpeedOfSound
{nullptr};
124 LPALDISTANCEMODEL alDistanceModel
{nullptr};
127 DriverIface(T
&& name
, HMODULE mod
)
128 : Name(std::forward
<T
>(name
)), Module(mod
)
138 extern std::vector
<DriverIface
> DriverList
;
140 extern thread_local DriverIface
*ThreadCtxDriver
;
141 extern std::atomic
<DriverIface
*> CurrentCtxDriver
;
143 /* HACK: MinGW generates bad code when accessing an extern thread_local object.
144 * Add a wrapper function for it that only accesses it where it's defined.
147 DriverIface
*GetThreadDriver() noexcept
;
148 void SetThreadDriver(DriverIface
*driver
) noexcept
;
150 inline DriverIface
*GetThreadDriver() noexcept
{ return ThreadCtxDriver
; }
151 inline void SetThreadDriver(DriverIface
*driver
) noexcept
{ ThreadCtxDriver
= driver
; }
156 void **mKeys
{nullptr};
157 /* Shares memory with keys. */
158 int *mValues
{nullptr};
161 ALsizei mCapacity
{0};
165 PtrIntMap() = default;
168 ALenum
insert(void *key
, int value
);
169 int removeByKey(void *key
);
170 int lookupByKey(void *key
);
180 extern enum LogLevel LogLevel
;
181 extern FILE *LogFile
;
183 #define TRACE(...) do { \
184 if(LogLevel >= LogLevel_Trace) \
186 fprintf(LogFile, "AL Router (II): " __VA_ARGS__); \
190 #define WARN(...) do { \
191 if(LogLevel >= LogLevel_Warn) \
193 fprintf(LogFile, "AL Router (WW): " __VA_ARGS__); \
197 #define ERR(...) do { \
198 if(LogLevel >= LogLevel_Error) \
200 fprintf(LogFile, "AL Router (EE): " __VA_ARGS__); \
205 #endif /* ROUTER_ROUTER_H */