aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--router/al.c20
-rw-r--r--router/router.h4
3 files changed, 19 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa863f64..4bba3c27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1284,7 +1284,7 @@ SET(EX_TARGET OpenAL)
if(WIN32 AND ALSOFT_BUILD_ROUTER)
SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME soft_oal)
- ADD_LIBRARY(Router SHARED router/router.c router/alc.c router/al.c)
+ ADD_LIBRARY(Router SHARED router/router.c router/alc.c router/al.c ${COMMON_OBJS})
SET_PROPERTY(TARGET Router APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS ${EXTRA_LDFLAGS})
IF(MSVC)
diff --git a/router/al.c b/router/al.c
index 8e179c82..63fca705 100644
--- a/router/al.c
+++ b/router/al.c
@@ -7,12 +7,20 @@
#include "router.h"
-#define DECL_THUNK0(R, n) AL_API R AL_APIENTRY n(void) { return (R)0; }
-#define DECL_THUNK1(R, n, T1) AL_API R AL_APIENTRY n(T1 a) { return (R)0; }
-#define DECL_THUNK2(R, n, T1, T2) AL_API R AL_APIENTRY n(T1 a, T2 b) { return (R)0; }
-#define DECL_THUNK3(R, n, T1, T2, T3) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c) { return (R)0; }
-#define DECL_THUNK4(R, n, T1, T2, T3, T4) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d) { return (R)0; }
-#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) { return (R)0; }
+ATOMIC(DriverIface*) CurrentCtxDriver = ATOMIC_INIT_STATIC(NULL);
+
+#define DECL_THUNK0(R, n) AL_API R AL_APIENTRY n(void) \
+{ return ATOMIC_LOAD_SEQ(&CurrentCtxDriver)->n(); }
+#define DECL_THUNK1(R, n, T1) AL_API R AL_APIENTRY n(T1 a) \
+{ return ATOMIC_LOAD_SEQ(&CurrentCtxDriver)->n(a); }
+#define DECL_THUNK2(R, n, T1, T2) AL_API R AL_APIENTRY n(T1 a, T2 b) \
+{ return ATOMIC_LOAD_SEQ(&CurrentCtxDriver)->n(a, b); }
+#define DECL_THUNK3(R, n, T1, T2, T3) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c)\
+{ return ATOMIC_LOAD_SEQ(&CurrentCtxDriver)->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) \
+{ return ATOMIC_LOAD_SEQ(&CurrentCtxDriver)->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)\
+{ return ATOMIC_LOAD_SEQ(&CurrentCtxDriver)->n(a, b, c, d, e); }
DECL_THUNK1(void, alDopplerFactor, ALfloat)
diff --git a/router/router.h b/router/router.h
index ee20bc17..57a32d9a 100644
--- a/router/router.h
+++ b/router/router.h
@@ -7,6 +7,7 @@
#include "AL/alc.h"
#include "AL/al.h"
+#include "atomic.h"
typedef struct DriverIface {
@@ -112,4 +113,7 @@ typedef struct DriverIface {
extern DriverIface *DriverList;
extern int DriverListSize;
+extern ATOMIC(DriverIface*) CurrentCtxDriver;
+
+
#endif /* ROUTER_ROUTER_H */