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