mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 20:20:11 +02:00
Update OpenAL-Soft to 1.22.0
This commit is contained in:
@@ -11,31 +11,31 @@ std::atomic<DriverIface*> CurrentCtxDriver{nullptr};
|
||||
|
||||
#define DECL_THUNK1(R,n,T1) AL_API R AL_APIENTRY n(T1 a) \
|
||||
{ \
|
||||
DriverIface *iface = ThreadCtxDriver; \
|
||||
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) \
|
||||
{ \
|
||||
DriverIface *iface = ThreadCtxDriver; \
|
||||
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) \
|
||||
{ \
|
||||
DriverIface *iface = ThreadCtxDriver; \
|
||||
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) \
|
||||
{ \
|
||||
DriverIface *iface = ThreadCtxDriver; \
|
||||
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) \
|
||||
{ \
|
||||
DriverIface *iface = ThreadCtxDriver; \
|
||||
DriverIface *iface = GetThreadDriver(); \
|
||||
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire); \
|
||||
return iface->n(a, b, c, d, e); \
|
||||
}
|
||||
@@ -46,7 +46,7 @@ std::atomic<DriverIface*> CurrentCtxDriver{nullptr};
|
||||
*/
|
||||
AL_API ALenum AL_APIENTRY alGetError(void)
|
||||
{
|
||||
DriverIface *iface = ThreadCtxDriver;
|
||||
DriverIface *iface = GetThreadDriver();
|
||||
if(!iface) iface = CurrentCtxDriver.load(std::memory_order_acquire);
|
||||
return iface ? iface->alGetError() : AL_NO_ERROR;
|
||||
}
|
||||
@@ -130,39 +130,3 @@ 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)
|
||||
|
||||
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*)
|
||||
|
||||
@@ -118,40 +118,6 @@ static const std::array<FuncExportEntry,128> alcFunctions{{
|
||||
DECL(alDopplerVelocity),
|
||||
DECL(alSpeedOfSound),
|
||||
DECL(alDistanceModel),
|
||||
|
||||
DECL(alGenFilters),
|
||||
DECL(alDeleteFilters),
|
||||
DECL(alIsFilter),
|
||||
DECL(alFilterf),
|
||||
DECL(alFilterfv),
|
||||
DECL(alFilteri),
|
||||
DECL(alFilteriv),
|
||||
DECL(alGetFilterf),
|
||||
DECL(alGetFilterfv),
|
||||
DECL(alGetFilteri),
|
||||
DECL(alGetFilteriv),
|
||||
DECL(alGenEffects),
|
||||
DECL(alDeleteEffects),
|
||||
DECL(alIsEffect),
|
||||
DECL(alEffectf),
|
||||
DECL(alEffectfv),
|
||||
DECL(alEffecti),
|
||||
DECL(alEffectiv),
|
||||
DECL(alGetEffectf),
|
||||
DECL(alGetEffectfv),
|
||||
DECL(alGetEffecti),
|
||||
DECL(alGetEffectiv),
|
||||
DECL(alGenAuxiliaryEffectSlots),
|
||||
DECL(alDeleteAuxiliaryEffectSlots),
|
||||
DECL(alIsAuxiliaryEffectSlot),
|
||||
DECL(alAuxiliaryEffectSlotf),
|
||||
DECL(alAuxiliaryEffectSlotfv),
|
||||
DECL(alAuxiliaryEffectSloti),
|
||||
DECL(alAuxiliaryEffectSlotiv),
|
||||
DECL(alGetAuxiliaryEffectSlotf),
|
||||
DECL(alGetAuxiliaryEffectSlotfv),
|
||||
DECL(alGetAuxiliaryEffectSloti),
|
||||
DECL(alGetAuxiliaryEffectSlotiv),
|
||||
}};
|
||||
#undef DECL
|
||||
|
||||
@@ -469,21 +435,21 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
|
||||
*/
|
||||
if(idx < 0)
|
||||
{
|
||||
DriverIface *oldiface = ThreadCtxDriver;
|
||||
DriverIface *oldiface = GetThreadDriver();
|
||||
if(oldiface) oldiface->alcSetThreadContext(nullptr);
|
||||
oldiface = CurrentCtxDriver.exchange(nullptr);
|
||||
if(oldiface) oldiface->alcMakeContextCurrent(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
DriverIface *oldiface = ThreadCtxDriver;
|
||||
DriverIface *oldiface = GetThreadDriver();
|
||||
if(oldiface && oldiface != &DriverList[idx])
|
||||
oldiface->alcSetThreadContext(nullptr);
|
||||
oldiface = CurrentCtxDriver.exchange(&DriverList[idx]);
|
||||
if(oldiface && oldiface != &DriverList[idx])
|
||||
oldiface->alcMakeContextCurrent(nullptr);
|
||||
}
|
||||
ThreadCtxDriver = nullptr;
|
||||
SetThreadDriver(nullptr);
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
@@ -526,7 +492,7 @@ ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
||||
|
||||
ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
|
||||
{
|
||||
DriverIface *iface = ThreadCtxDriver;
|
||||
DriverIface *iface = GetThreadDriver();
|
||||
if(!iface) iface = CurrentCtxDriver.load();
|
||||
return iface ? iface->alcGetCurrentContext() : nullptr;
|
||||
}
|
||||
@@ -932,10 +898,10 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
|
||||
|
||||
if(!context)
|
||||
{
|
||||
DriverIface *oldiface = ThreadCtxDriver;
|
||||
DriverIface *oldiface = GetThreadDriver();
|
||||
if(oldiface && !oldiface->alcSetThreadContext(nullptr))
|
||||
return ALC_FALSE;
|
||||
ThreadCtxDriver = nullptr;
|
||||
SetThreadDriver(nullptr);
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
@@ -944,10 +910,10 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
|
||||
{
|
||||
if(DriverList[idx].alcSetThreadContext(context))
|
||||
{
|
||||
DriverIface *oldiface = ThreadCtxDriver;
|
||||
DriverIface *oldiface = GetThreadDriver();
|
||||
if(oldiface != &DriverList[idx])
|
||||
{
|
||||
ThreadCtxDriver = &DriverList[idx];
|
||||
SetThreadDriver(&DriverList[idx]);
|
||||
if(oldiface) oldiface->alcSetThreadContext(nullptr);
|
||||
}
|
||||
return ALC_TRUE;
|
||||
@@ -960,7 +926,7 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
|
||||
|
||||
ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void)
|
||||
{
|
||||
DriverIface *iface = ThreadCtxDriver;
|
||||
DriverIface *iface = GetThreadDriver();
|
||||
if(iface) return iface->alcGetThreadContext();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,11 @@ 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);
|
||||
|
||||
|
||||
@@ -209,7 +214,10 @@ static void AddModule(HMODULE module, const WCHAR *name)
|
||||
if(newdrv.alcGetError(nullptr) == ALC_NO_ERROR)
|
||||
newdrv.ALCVer = MAKE_ALC_VER(alc_ver[0], alc_ver[1]);
|
||||
else
|
||||
{
|
||||
WARN("Failed to query ALC version for %ls, assuming 1.0\n", name);
|
||||
newdrv.ALCVer = MAKE_ALC_VER(1, 0);
|
||||
}
|
||||
|
||||
#undef LOAD_PROC
|
||||
#define LOAD_PROC(x) do { \
|
||||
@@ -226,42 +234,6 @@ static void AddModule(HMODULE module, const WCHAR *name)
|
||||
LOAD_PROC(alcSetThreadContext);
|
||||
LOAD_PROC(alcGetThreadContext);
|
||||
}
|
||||
if(newdrv.alcIsExtensionPresent(nullptr, "ALC_EXT_EFX"))
|
||||
{
|
||||
LOAD_PROC(alGenFilters);
|
||||
LOAD_PROC(alDeleteFilters);
|
||||
LOAD_PROC(alIsFilter);
|
||||
LOAD_PROC(alFilterf);
|
||||
LOAD_PROC(alFilterfv);
|
||||
LOAD_PROC(alFilteri);
|
||||
LOAD_PROC(alFilteriv);
|
||||
LOAD_PROC(alGetFilterf);
|
||||
LOAD_PROC(alGetFilterfv);
|
||||
LOAD_PROC(alGetFilteri);
|
||||
LOAD_PROC(alGetFilteriv);
|
||||
LOAD_PROC(alGenEffects);
|
||||
LOAD_PROC(alDeleteEffects);
|
||||
LOAD_PROC(alIsEffect);
|
||||
LOAD_PROC(alEffectf);
|
||||
LOAD_PROC(alEffectfv);
|
||||
LOAD_PROC(alEffecti);
|
||||
LOAD_PROC(alEffectiv);
|
||||
LOAD_PROC(alGetEffectf);
|
||||
LOAD_PROC(alGetEffectfv);
|
||||
LOAD_PROC(alGetEffecti);
|
||||
LOAD_PROC(alGetEffectiv);
|
||||
LOAD_PROC(alGenAuxiliaryEffectSlots);
|
||||
LOAD_PROC(alDeleteAuxiliaryEffectSlots);
|
||||
LOAD_PROC(alIsAuxiliaryEffectSlot);
|
||||
LOAD_PROC(alAuxiliaryEffectSlotf);
|
||||
LOAD_PROC(alAuxiliaryEffectSlotfv);
|
||||
LOAD_PROC(alAuxiliaryEffectSloti);
|
||||
LOAD_PROC(alAuxiliaryEffectSlotiv);
|
||||
LOAD_PROC(alGetAuxiliaryEffectSlotf);
|
||||
LOAD_PROC(alGetAuxiliaryEffectSlotfv);
|
||||
LOAD_PROC(alGetAuxiliaryEffectSloti);
|
||||
LOAD_PROC(alGetAuxiliaryEffectSlotiv);
|
||||
}
|
||||
}
|
||||
|
||||
if(err)
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "AL/alc.h"
|
||||
#include "AL/al.h"
|
||||
@@ -122,42 +123,9 @@ struct DriverIface {
|
||||
LPALSPEEDOFSOUND alSpeedOfSound{nullptr};
|
||||
LPALDISTANCEMODEL alDistanceModel{nullptr};
|
||||
|
||||
LPALGENFILTERS alGenFilters{nullptr};
|
||||
LPALDELETEFILTERS alDeleteFilters{nullptr};
|
||||
LPALISFILTER alIsFilter{nullptr};
|
||||
LPALFILTERF alFilterf{nullptr};
|
||||
LPALFILTERFV alFilterfv{nullptr};
|
||||
LPALFILTERI alFilteri{nullptr};
|
||||
LPALFILTERIV alFilteriv{nullptr};
|
||||
LPALGETFILTERF alGetFilterf{nullptr};
|
||||
LPALGETFILTERFV alGetFilterfv{nullptr};
|
||||
LPALGETFILTERI alGetFilteri{nullptr};
|
||||
LPALGETFILTERIV alGetFilteriv{nullptr};
|
||||
LPALGENEFFECTS alGenEffects{nullptr};
|
||||
LPALDELETEEFFECTS alDeleteEffects{nullptr};
|
||||
LPALISEFFECT alIsEffect{nullptr};
|
||||
LPALEFFECTF alEffectf{nullptr};
|
||||
LPALEFFECTFV alEffectfv{nullptr};
|
||||
LPALEFFECTI alEffecti{nullptr};
|
||||
LPALEFFECTIV alEffectiv{nullptr};
|
||||
LPALGETEFFECTF alGetEffectf{nullptr};
|
||||
LPALGETEFFECTFV alGetEffectfv{nullptr};
|
||||
LPALGETEFFECTI alGetEffecti{nullptr};
|
||||
LPALGETEFFECTIV alGetEffectiv{nullptr};
|
||||
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots{nullptr};
|
||||
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots{nullptr};
|
||||
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot{nullptr};
|
||||
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf{nullptr};
|
||||
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv{nullptr};
|
||||
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti{nullptr};
|
||||
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv{nullptr};
|
||||
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf{nullptr};
|
||||
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv{nullptr};
|
||||
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti{nullptr};
|
||||
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv{nullptr};
|
||||
|
||||
DriverIface(std::wstring name, HMODULE mod)
|
||||
: Name(std::move(name)), Module(mod)
|
||||
template<typename T>
|
||||
DriverIface(T&& name, HMODULE mod)
|
||||
: Name(std::forward<T>(name)), Module(mod)
|
||||
{ }
|
||||
~DriverIface()
|
||||
{
|
||||
@@ -172,6 +140,17 @@ extern std::vector<DriverIface> 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 DriverIface *GetThreadDriver() noexcept { return ThreadCtxDriver; }
|
||||
inline void SetThreadDriver(DriverIface *driver) noexcept { ThreadCtxDriver = driver; }
|
||||
#endif
|
||||
|
||||
|
||||
class PtrIntMap {
|
||||
void **mKeys{nullptr};
|
||||
|
||||
Reference in New Issue
Block a user