Properly initialize with the default distance model
[openal-soft.git] / router / al.c
blob8dd888d9734f1c482fcba997092e62a88e97fd6e
2 #include "config.h"
4 #include <stddef.h>
6 #include "AL/al.h"
7 #include "router.h"
10 atomic_DriverIfacePtr CurrentCtxDriver = ATOMIC_INIT_STATIC(NULL);
12 #define DECL_THUNK1(R,n,T1) AL_API R AL_APIENTRY n(T1 a) \
13 { \
14 DriverIface *iface = altss_get(ThreadCtxDriver); \
15 if(!iface) iface = ATOMIC_LOAD(&CurrentCtxDriver, almemory_order_acquire);\
16 return iface->n(a); \
18 #define DECL_THUNK2(R,n,T1,T2) AL_API R AL_APIENTRY n(T1 a, T2 b) \
19 { \
20 DriverIface *iface = altss_get(ThreadCtxDriver); \
21 if(!iface) iface = ATOMIC_LOAD(&CurrentCtxDriver, almemory_order_acquire);\
22 return iface->n(a, b); \
24 #define DECL_THUNK3(R,n,T1,T2,T3) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c) \
25 { \
26 DriverIface *iface = altss_get(ThreadCtxDriver); \
27 if(!iface) iface = ATOMIC_LOAD(&CurrentCtxDriver, almemory_order_acquire);\
28 return iface->n(a, b, c); \
30 #define DECL_THUNK4(R,n,T1,T2,T3,T4) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d) \
31 { \
32 DriverIface *iface = altss_get(ThreadCtxDriver); \
33 if(!iface) iface = ATOMIC_LOAD(&CurrentCtxDriver, almemory_order_acquire);\
34 return iface->n(a, b, c, d); \
36 #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) \
37 { \
38 DriverIface *iface = altss_get(ThreadCtxDriver); \
39 if(!iface) iface = ATOMIC_LOAD(&CurrentCtxDriver, almemory_order_acquire);\
40 return iface->n(a, b, c, d, e); \
44 /* Ugly hack for some apps calling alGetError without a current context, and
45 * expecting it to be AL_NO_ERROR.
47 AL_API ALenum AL_APIENTRY alGetError(void)
49 DriverIface *iface = altss_get(ThreadCtxDriver);
50 if(!iface) iface = ATOMIC_LOAD(&CurrentCtxDriver, almemory_order_acquire);
51 return iface ? iface->alGetError() : AL_NO_ERROR;
55 DECL_THUNK1(void, alDopplerFactor, ALfloat)
56 DECL_THUNK1(void, alDopplerVelocity, ALfloat)
57 DECL_THUNK1(void, alSpeedOfSound, ALfloat)
58 DECL_THUNK1(void, alDistanceModel, ALenum)
60 DECL_THUNK1(void, alEnable, ALenum)
61 DECL_THUNK1(void, alDisable, ALenum)
62 DECL_THUNK1(ALboolean, alIsEnabled, ALenum)
64 DECL_THUNK1(const ALchar*, alGetString, ALenum)
65 DECL_THUNK2(void, alGetBooleanv, ALenum, ALboolean*)
66 DECL_THUNK2(void, alGetIntegerv, ALenum, ALint*)
67 DECL_THUNK2(void, alGetFloatv, ALenum, ALfloat*)
68 DECL_THUNK2(void, alGetDoublev, ALenum, ALdouble*)
69 DECL_THUNK1(ALboolean, alGetBoolean, ALenum)
70 DECL_THUNK1(ALint, alGetInteger, ALenum)
71 DECL_THUNK1(ALfloat, alGetFloat, ALenum)
72 DECL_THUNK1(ALdouble, alGetDouble, ALenum)
74 DECL_THUNK1(ALboolean, alIsExtensionPresent, const ALchar*)
75 DECL_THUNK1(void*, alGetProcAddress, const ALchar*)
76 DECL_THUNK1(ALenum, alGetEnumValue, const ALchar*)
78 DECL_THUNK2(void, alListenerf, ALenum, ALfloat)
79 DECL_THUNK4(void, alListener3f, ALenum, ALfloat, ALfloat, ALfloat)
80 DECL_THUNK2(void, alListenerfv, ALenum, const ALfloat*)
81 DECL_THUNK2(void, alListeneri, ALenum, ALint)
82 DECL_THUNK4(void, alListener3i, ALenum, ALint, ALint, ALint)
83 DECL_THUNK2(void, alListeneriv, ALenum, const ALint*)
84 DECL_THUNK2(void, alGetListenerf, ALenum, ALfloat*)
85 DECL_THUNK4(void, alGetListener3f, ALenum, ALfloat*, ALfloat*, ALfloat*)
86 DECL_THUNK2(void, alGetListenerfv, ALenum, ALfloat*)
87 DECL_THUNK2(void, alGetListeneri, ALenum, ALint*)
88 DECL_THUNK4(void, alGetListener3i, ALenum, ALint*, ALint*, ALint*)
89 DECL_THUNK2(void, alGetListeneriv, ALenum, ALint*)
91 DECL_THUNK2(void, alGenSources, ALsizei, ALuint*)
92 DECL_THUNK2(void, alDeleteSources, ALsizei, const ALuint*)
93 DECL_THUNK1(ALboolean, alIsSource, ALuint)
94 DECL_THUNK3(void, alSourcef, ALuint, ALenum, ALfloat)
95 DECL_THUNK5(void, alSource3f, ALuint, ALenum, ALfloat, ALfloat, ALfloat)
96 DECL_THUNK3(void, alSourcefv, ALuint, ALenum, const ALfloat*)
97 DECL_THUNK3(void, alSourcei, ALuint, ALenum, ALint)
98 DECL_THUNK5(void, alSource3i, ALuint, ALenum, ALint, ALint, ALint)
99 DECL_THUNK3(void, alSourceiv, ALuint, ALenum, const ALint*)
100 DECL_THUNK3(void, alGetSourcef, ALuint, ALenum, ALfloat*)
101 DECL_THUNK5(void, alGetSource3f, ALuint, ALenum, ALfloat*, ALfloat*, ALfloat*)
102 DECL_THUNK3(void, alGetSourcefv, ALuint, ALenum, ALfloat*)
103 DECL_THUNK3(void, alGetSourcei, ALuint, ALenum, ALint*)
104 DECL_THUNK5(void, alGetSource3i, ALuint, ALenum, ALint*, ALint*, ALint*)
105 DECL_THUNK3(void, alGetSourceiv, ALuint, ALenum, ALint*)
106 DECL_THUNK2(void, alSourcePlayv, ALsizei, const ALuint*)
107 DECL_THUNK2(void, alSourceStopv, ALsizei, const ALuint*)
108 DECL_THUNK2(void, alSourceRewindv, ALsizei, const ALuint*)
109 DECL_THUNK2(void, alSourcePausev, ALsizei, const ALuint*)
110 DECL_THUNK1(void, alSourcePlay, ALuint)
111 DECL_THUNK1(void, alSourceStop, ALuint)
112 DECL_THUNK1(void, alSourceRewind, ALuint)
113 DECL_THUNK1(void, alSourcePause, ALuint)
114 DECL_THUNK3(void, alSourceQueueBuffers, ALuint, ALsizei, const ALuint*)
115 DECL_THUNK3(void, alSourceUnqueueBuffers, ALuint, ALsizei, ALuint*)
117 DECL_THUNK2(void, alGenBuffers, ALsizei, ALuint*)
118 DECL_THUNK2(void, alDeleteBuffers, ALsizei, const ALuint*)
119 DECL_THUNK1(ALboolean, alIsBuffer, ALuint)
120 DECL_THUNK3(void, alBufferf, ALuint, ALenum, ALfloat)
121 DECL_THUNK5(void, alBuffer3f, ALuint, ALenum, ALfloat, ALfloat, ALfloat)
122 DECL_THUNK3(void, alBufferfv, ALuint, ALenum, const ALfloat*)
123 DECL_THUNK3(void, alBufferi, ALuint, ALenum, ALint)
124 DECL_THUNK5(void, alBuffer3i, ALuint, ALenum, ALint, ALint, ALint)
125 DECL_THUNK3(void, alBufferiv, ALuint, ALenum, const ALint*)
126 DECL_THUNK3(void, alGetBufferf, ALuint, ALenum, ALfloat*)
127 DECL_THUNK5(void, alGetBuffer3f, ALuint, ALenum, ALfloat*, ALfloat*, ALfloat*)
128 DECL_THUNK3(void, alGetBufferfv, ALuint, ALenum, ALfloat*)
129 DECL_THUNK3(void, alGetBufferi, ALuint, ALenum, ALint*)
130 DECL_THUNK5(void, alGetBuffer3i, ALuint, ALenum, ALint*, ALint*, ALint*)
131 DECL_THUNK3(void, alGetBufferiv, ALuint, ALenum, ALint*)
132 DECL_THUNK5(void, alBufferData, ALuint, ALenum, const ALvoid*, ALsizei, ALsizei)