aboutsummaryrefslogtreecommitdiffstats
path: root/router/al.cpp
blob: c7e01d51000678cc524cf00f6c842cb2ef394e0c (plain)
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

#include "config.h"

#include <stddef.h>

#include "AL/al.h"
#include "router.h"


std::atomic<DriverIface*> CurrentCtxDriver{nullptr};

#define DECL_THUNK1(R,n,T1) AL_API R AL_APIENTRY n(T1 a) noexcept             \
{                                                                             \
    DriverIface *iface = GetThreadDriver();                                   \
    if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);      \
    return iface->n(a);                                                       \
}
#define DECL_THUNK2(R,n,T1,T2) AL_API R AL_APIENTRY n(T1 a, T2 b) noexcept    \
{                                                                             \
    DriverIface *iface = GetThreadDriver();                                   \
    if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);      \
    return iface->n(a, b);                                                    \
}
#define DECL_THUNK3(R,n,T1,T2,T3) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c) noexcept \
{                                                                             \
    DriverIface *iface = GetThreadDriver();                                   \
    if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);      \
    return iface->n(a, b, c);                                                 \
}
#define DECL_THUNK4(R,n,T1,T2,T3,T4) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d) noexcept \
{                                                                             \
    DriverIface *iface = GetThreadDriver();                                   \
    if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);      \
    return iface->n(a, b, c, d);                                              \
}
#define DECL_THUNK5(R,n,T1,T2,T3,T4,T5) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d, T5 e) noexcept \
{                                                                             \
    DriverIface *iface = GetThreadDriver();                                   \
    if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);      \
    return iface->n(a, b, c, d, e);                                           \
}


/* Ugly hack for some apps calling alGetError without a current context, and
 * expecting it to be AL_NO_ERROR.
 */
AL_API ALenum AL_APIENTRY alGetError(void) noexcept
{
    DriverIface *iface = GetThreadDriver();
    if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);
    return iface ? iface->alGetError() : AL_NO_ERROR;
}


DECL_THUNK1(void, alDopplerFactor, ALfloat)
DECL_THUNK1(void, alDopplerVelocity, ALfloat)
DECL_THUNK1(void, alSpeedOfSound, ALfloat)
DECL_THUNK1(void, alDistanceModel, ALenum)

DECL_THUNK1(void, alEnable, ALenum)
DECL_THUNK1(void, alDisable, ALenum)
DECL_THUNK1(ALboolean, alIsEnabled, ALenum)

DECL_THUNK1(const ALchar*, alGetString, ALenum)
DECL_THUNK2(void, alGetBooleanv, ALenum, ALboolean*)
DECL_THUNK2(void, alGetIntegerv, ALenum, ALint*)
DECL_THUNK2(void, alGetFloatv, ALenum, ALfloat*)
DECL_THUNK2(void, alGetDoublev, ALenum, ALdouble*)
DECL_THUNK1(ALboolean, alGetBoolean, ALenum)
DECL_THUNK1(ALint, alGetInteger, ALenum)
DECL_THUNK1(ALfloat, alGetFloat, ALenum)
DECL_THUNK1(ALdouble, alGetDouble, ALenum)

DECL_THUNK1(ALboolean, alIsExtensionPresent, const ALchar*)
DECL_THUNK1(void*, alGetProcAddress, const ALchar*)
DECL_THUNK1(ALenum, alGetEnumValue, const ALchar*)

DECL_THUNK2(void, alListenerf, ALenum, ALfloat)
DECL_THUNK4(void, alListener3f, ALenum, ALfloat, ALfloat, ALfloat)
DECL_THUNK2(void, alListenerfv, ALenum, const ALfloat*)
DECL_THUNK2(void, alListeneri, ALenum, ALint)
DECL_THUNK4(void, alListener3i, ALenum, ALint, ALint, ALint)
DECL_THUNK2(void, alListeneriv, ALenum, const ALint*)
DECL_THUNK2(void, alGetListenerf, ALenum, ALfloat*)
DECL_THUNK4(void, alGetListener3f, ALenum, ALfloat*, ALfloat*, ALfloat*)
DECL_THUNK2(void, alGetListenerfv, ALenum, ALfloat*)
DECL_THUNK2(void, alGetListeneri, ALenum, ALint*)
DECL_THUNK4(void, alGetListener3i, ALenum, ALint*, ALint*, ALint*)
DECL_THUNK2(void, alGetListeneriv, ALenum, ALint*)

DECL_THUNK2(void, alGenSources, ALsizei, ALuint*)
DECL_THUNK2(void, alDeleteSources, ALsizei, const ALuint*)
DECL_THUNK1(ALboolean, alIsSource, ALuint)
DECL_THUNK3(void, alSourcef, ALuint, ALenum, ALfloat)
DECL_THUNK5(void, alSource3f, ALuint, ALenum, ALfloat, ALfloat, ALfloat)
DECL_THUNK3(void, alSourcefv, ALuint, ALenum, const ALfloat*)
DECL_THUNK3(void, alSourcei, ALuint, ALenum, ALint)
DECL_THUNK5(void, alSource3i, ALuint, ALenum, ALint, ALint, ALint)
DECL_THUNK3(void, alSourceiv, ALuint, ALenum, const ALint*)
DECL_THUNK3(void, alGetSourcef, ALuint, ALenum, ALfloat*)
DECL_THUNK5(void, alGetSource3f, ALuint, ALenum, ALfloat*, ALfloat*, ALfloat*)
DECL_THUNK3(void, alGetSourcefv, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetSourcei, ALuint, ALenum, ALint*)
DECL_THUNK5(void, alGetSource3i, ALuint, ALenum, ALint*, ALint*, ALint*)
DECL_THUNK3(void, alGetSourceiv, ALuint, ALenum, ALint*)
DECL_THUNK2(void, alSourcePlayv, ALsizei, const ALuint*)
DECL_THUNK2(void, alSourceStopv, ALsizei, const ALuint*)
DECL_THUNK2(void, alSourceRewindv, ALsizei, const ALuint*)
DECL_THUNK2(void, alSourcePausev, ALsizei, const ALuint*)
DECL_THUNK1(void, alSourcePlay, ALuint)
DECL_THUNK1(void, alSourceStop, ALuint)
DECL_THUNK1(void, alSourceRewind, ALuint)
DECL_THUNK1(void, alSourcePause, ALuint)
DECL_THUNK3(void, alSourceQueueBuffers, ALuint, ALsizei, const ALuint*)
DECL_THUNK3(void, alSourceUnqueueBuffers, ALuint, ALsizei, ALuint*)

DECL_THUNK2(void, alGenBuffers, ALsizei, ALuint*)
DECL_THUNK2(void, alDeleteBuffers, ALsizei, const ALuint*)
DECL_THUNK1(ALboolean, alIsBuffer, ALuint)
DECL_THUNK3(void, alBufferf, ALuint, ALenum, ALfloat)
DECL_THUNK5(void, alBuffer3f, ALuint, ALenum, ALfloat, ALfloat, ALfloat)
DECL_THUNK3(void, alBufferfv, ALuint, ALenum, const ALfloat*)
DECL_THUNK3(void, alBufferi, ALuint, ALenum, ALint)
DECL_THUNK5(void, alBuffer3i, ALuint, ALenum, ALint, ALint, ALint)
DECL_THUNK3(void, alBufferiv, ALuint, ALenum, const ALint*)
DECL_THUNK3(void, alGetBufferf, ALuint, ALenum, ALfloat*)
DECL_THUNK5(void, alGetBuffer3f, ALuint, ALenum, ALfloat*, ALfloat*, ALfloat*)
DECL_THUNK3(void, alGetBufferfv, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetBufferi, ALuint, ALenum, ALint*)
DECL_THUNK5(void, alGetBuffer3i, ALuint, ALenum, ALint*, ALint*, ALint*)
DECL_THUNK3(void, alGetBufferiv, ALuint, ALenum, ALint*)
DECL_THUNK5(void, alBufferData, ALuint, ALenum, const ALvoid*, ALsizei, ALsizei)

/* EFX 1.0. Required here to be exported from libOpenAL32.dll.a/OpenAL32.lib
 * with the router enabled.
 */
DECL_THUNK2(void, alGenFilters, ALsizei, ALuint*)
DECL_THUNK2(void, alDeleteFilters, ALsizei, const ALuint*)
DECL_THUNK1(ALboolean, alIsFilter, ALuint)
DECL_THUNK3(void, alFilterf, ALuint, ALenum, ALfloat)
DECL_THUNK3(void, alFilterfv, ALuint, ALenum, const ALfloat*)
DECL_THUNK3(void, alFilteri, ALuint, ALenum, ALint)
DECL_THUNK3(void, alFilteriv, ALuint, ALenum, const ALint*)
DECL_THUNK3(void, alGetFilterf, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetFilterfv, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetFilteri, ALuint, ALenum, ALint*)
DECL_THUNK3(void, alGetFilteriv, ALuint, ALenum, ALint*)

DECL_THUNK2(void, alGenEffects, ALsizei, ALuint*)
DECL_THUNK2(void, alDeleteEffects, ALsizei, const ALuint*)
DECL_THUNK1(ALboolean, alIsEffect, ALuint)
DECL_THUNK3(void, alEffectf, ALuint, ALenum, ALfloat)
DECL_THUNK3(void, alEffectfv, ALuint, ALenum, const ALfloat*)
DECL_THUNK3(void, alEffecti, ALuint, ALenum, ALint)
DECL_THUNK3(void, alEffectiv, ALuint, ALenum, const ALint*)
DECL_THUNK3(void, alGetEffectf, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetEffectfv, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetEffecti, ALuint, ALenum, ALint*)
DECL_THUNK3(void, alGetEffectiv, ALuint, ALenum, ALint*)

DECL_THUNK2(void, alGenAuxiliaryEffectSlots, ALsizei, ALuint*)
DECL_THUNK2(void, alDeleteAuxiliaryEffectSlots, ALsizei, const ALuint*)
DECL_THUNK1(ALboolean, alIsAuxiliaryEffectSlot, ALuint)
DECL_THUNK3(void, alAuxiliaryEffectSlotf, ALuint, ALenum, ALfloat)
DECL_THUNK3(void, alAuxiliaryEffectSlotfv, ALuint, ALenum, const ALfloat*)
DECL_THUNK3(void, alAuxiliaryEffectSloti, ALuint, ALenum, ALint)
DECL_THUNK3(void, alAuxiliaryEffectSlotiv, ALuint, ALenum, const ALint*)
DECL_THUNK3(void, alGetAuxiliaryEffectSlotf, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetAuxiliaryEffectSlotfv, ALuint, ALenum, ALfloat*)
DECL_THUNK3(void, alGetAuxiliaryEffectSloti, ALuint, ALenum, ALint*)
DECL_THUNK3(void, alGetAuxiliaryEffectSlotiv, ALuint, ALenum, ALint*)