aboutsummaryrefslogtreecommitdiffstats
path: root/router
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-11-28 12:51:46 +0100
committerSven Gothel <[email protected]>2023-11-28 12:51:46 +0100
commit1aaf4f070011490bcece50394b9b32dfa593fd9e (patch)
tree17d68284e401a35eea3d3a574d986d446a60763a /router
parent6e7cee4fa9a8af03f28ca26cd89f8357390dfc90 (diff)
parent571b546f35eead77ce109f8d4dd6c3de3199d573 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'router')
-rw-r--r--router/al.cpp14
-rw-r--r--router/alc.cpp44
-rw-r--r--router/router.cpp14
-rw-r--r--router/router.h18
4 files changed, 35 insertions, 55 deletions
diff --git a/router/al.cpp b/router/al.cpp
index 06c314eb..6ed8a626 100644
--- a/router/al.cpp
+++ b/router/al.cpp
@@ -7,33 +7,31 @@
#include "router.h"
-std::atomic<DriverIface*> CurrentCtxDriver{nullptr};
-
-#define DECL_THUNK1(R,n,T1) AL_API R AL_APIENTRY n(T1 a) \
+#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) \
+#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) \
+#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) \
+#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) \
+#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); \
@@ -44,7 +42,7 @@ std::atomic<DriverIface*> CurrentCtxDriver{nullptr};
/* 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)
+AL_API ALenum AL_APIENTRY alGetError(void) noexcept
{
DriverIface *iface = GetThreadDriver();
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);
diff --git a/router/alc.cpp b/router/alc.cpp
index 3aa3382b..fe9faa45 100644
--- a/router/alc.cpp
+++ b/router/alc.cpp
@@ -394,7 +394,7 @@ static void InitCtxFuncs(DriverIface &iface)
}
-ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
+ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename) noexcept
{
ALCdevice *device = nullptr;
ALint idx = 0;
@@ -459,7 +459,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
return device;
}
-ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device)
+ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device) noexcept
{
ALint idx;
@@ -475,7 +475,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device)
}
-ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrlist)
+ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrlist) noexcept
{
ALCcontext *context;
ALint idx;
@@ -498,7 +498,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
return context;
}
-ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
+ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) noexcept
{
ALint idx = -1;
@@ -542,7 +542,7 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
return ALC_TRUE;
}
-ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context)
+ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context) noexcept
{
if(context)
{
@@ -553,7 +553,7 @@ ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context)
LastError.store(ALC_INVALID_CONTEXT);
}
-ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context)
+ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context) noexcept
{
if(context)
{
@@ -564,7 +564,7 @@ ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context)
LastError.store(ALC_INVALID_CONTEXT);
}
-ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context)
+ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context) noexcept
{
ALint idx;
@@ -578,14 +578,14 @@ ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context)
ContextIfaceMap.removeByKey(context);
}
-ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
+ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void) noexcept
{
DriverIface *iface = GetThreadDriver();
if(!iface) iface = CurrentCtxDriver.load();
return iface ? iface->alcGetCurrentContext() : nullptr;
}
-ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context)
+ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context) noexcept
{
if(context)
{
@@ -598,7 +598,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context)
}
-ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device)
+ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) noexcept
{
if(device)
{
@@ -609,7 +609,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device)
return LastError.exchange(ALC_NO_ERROR);
}
-ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname)
+ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname) noexcept
{
const char *ptr;
size_t len;
@@ -641,7 +641,7 @@ ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const A
return ALC_FALSE;
}
-ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname)
+ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname) noexcept
{
if(device)
{
@@ -661,7 +661,7 @@ ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *f
return (iter != alcFunctions.cend()) ? iter->address : nullptr;
}
-ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname)
+ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname) noexcept
{
if(device)
{
@@ -681,7 +681,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *e
return (iter != alcEnumerations.cend()) ? iter->value : 0;
}
-ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param)
+ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param) noexcept
{
if(device)
{
@@ -817,7 +817,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
return nullptr;
}
-ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values)
+ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values) noexcept
{
if(device)
{
@@ -872,7 +872,7 @@ ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsi
}
-ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize)
+ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize) noexcept
{
ALCdevice *device = nullptr;
ALint idx = 0;
@@ -924,7 +924,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename,
return device;
}
-ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device)
+ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device) noexcept
{
ALint idx;
@@ -939,7 +939,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device)
return ALC_TRUE;
}
-ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device)
+ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device) noexcept
{
if(device)
{
@@ -950,7 +950,7 @@ ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device)
LastError.store(ALC_INVALID_DEVICE);
}
-ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device)
+ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device) noexcept
{
if(device)
{
@@ -961,7 +961,7 @@ ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device)
LastError.store(ALC_INVALID_DEVICE);
}
-ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
+ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) noexcept
{
if(device)
{
@@ -973,7 +973,7 @@ ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer,
}
-ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
+ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) noexcept
{
ALCenum err = ALC_INVALID_CONTEXT;
ALint idx;
@@ -1009,7 +1009,7 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
return ALC_FALSE;
}
-ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void)
+ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void) noexcept
{
DriverIface *iface = GetThreadDriver();
if(iface) return iface->alcGetThreadContext();
diff --git a/router/router.cpp b/router/router.cpp
index 3c891053..e2ba91d1 100644
--- a/router/router.cpp
+++ b/router/router.cpp
@@ -17,18 +17,9 @@
#include "version.h"
-std::vector<DriverIfacePtr> DriverList;
-
-thread_local DriverIface *ThreadCtxDriver;
-
enum LogLevel LogLevel = LogLevel_Error;
FILE *LogFile;
-#ifdef __MINGW32__
-DriverIface *GetThreadDriver() noexcept { return ThreadCtxDriver; }
-void SetThreadDriver(DriverIface *driver) noexcept { ThreadCtxDriver = driver; }
-#endif
-
static void LoadDriverList(void);
@@ -328,13 +319,12 @@ void LoadDriverList(void)
WCHAR cwd_path[MAX_PATH+1] = L"";
WCHAR proc_path[MAX_PATH+1] = L"";
WCHAR sys_path[MAX_PATH+1] = L"";
- int len;
if(GetLoadedModuleDirectory(L"OpenAL32.dll", dll_path, MAX_PATH))
TRACE("Got DLL path %ls\n", dll_path);
GetCurrentDirectoryW(MAX_PATH, cwd_path);
- len = lstrlenW(cwd_path);
+ auto len = wcslen(cwd_path);
if(len > 0 && (cwd_path[len-1] == '\\' || cwd_path[len-1] == '/'))
cwd_path[len-1] = '\0';
TRACE("Got current working directory %ls\n", cwd_path);
@@ -343,7 +333,7 @@ void LoadDriverList(void)
TRACE("Got proc path %ls\n", proc_path);
GetSystemDirectoryW(sys_path, MAX_PATH);
- len = lstrlenW(sys_path);
+ len = wcslen(sys_path);
if(len > 0 && (sys_path[len-1] == '\\' || sys_path[len-1] == '/'))
sys_path[len-1] = '\0';
TRACE("Got system path %ls\n", sys_path);
diff --git a/router/router.h b/router/router.h
index 2a126d42..f5c7f455 100644
--- a/router/router.h
+++ b/router/router.h
@@ -173,21 +173,13 @@ struct DriverIface {
};
using DriverIfacePtr = std::unique_ptr<DriverIface>;
-extern std::vector<DriverIfacePtr> DriverList;
-
-extern thread_local DriverIface *ThreadCtxDriver;
-extern std::atomic<DriverIface*> CurrentCtxDriver;
-
-/* HACK: MinGW generates bad code when accessing an extern thread_local object.
- * Add a wrapper function for it that only accesses it where it's defined.
- */
-#ifdef __MINGW32__
-DriverIface *GetThreadDriver() noexcept;
-void SetThreadDriver(DriverIface *driver) noexcept;
-#else
+inline std::vector<DriverIfacePtr> DriverList;
+
+inline thread_local DriverIface *ThreadCtxDriver{};
+inline std::atomic<DriverIface*> CurrentCtxDriver{};
+
inline DriverIface *GetThreadDriver() noexcept { return ThreadCtxDriver; }
inline void SetThreadDriver(DriverIface *driver) noexcept { ThreadCtxDriver = driver; }
-#endif
class PtrIntMap {