mirror of
https://github.com/love2d/megasource.git
synced 2026-08-17 03:02:49 +02:00
Update OpenAL-soft to 1.23.1-bc7cb17.
This commit is contained in:
+187
-101
@@ -6,9 +6,10 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
#include <tuple>
|
||||
|
||||
#include "AL/alc.h"
|
||||
#include "alstring.h"
|
||||
@@ -118,6 +119,41 @@ static const std::array<FuncExportEntry,128> alcFunctions{{
|
||||
DECL(alDopplerVelocity),
|
||||
DECL(alSpeedOfSound),
|
||||
DECL(alDistanceModel),
|
||||
|
||||
/* EFX 1.0 */
|
||||
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
|
||||
|
||||
@@ -309,7 +345,57 @@ static ALint GetDriverIndexForName(const EnumeratedList *list, const ALCchar *na
|
||||
}
|
||||
|
||||
|
||||
ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
|
||||
static void InitCtxFuncs(DriverIface &iface)
|
||||
{
|
||||
ALCdevice *device{iface.alcGetContextsDevice(iface.alcGetCurrentContext())};
|
||||
|
||||
#define LOAD_PROC(x) do { \
|
||||
iface.x = reinterpret_cast<decltype(iface.x)>(iface.alGetProcAddress(#x));\
|
||||
if(!iface.x) \
|
||||
ERR("Failed to find entry point for %s in %ls\n", #x, \
|
||||
iface.Name.c_str()); \
|
||||
} while(0)
|
||||
if(iface.alcIsExtensionPresent(device, "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);
|
||||
}
|
||||
#undef LOAD_PROC
|
||||
}
|
||||
|
||||
|
||||
ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename) noexcept
|
||||
{
|
||||
ALCdevice *device = nullptr;
|
||||
ALint idx = 0;
|
||||
@@ -326,14 +412,14 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
|
||||
if(devicename)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _{EnumerationLock};
|
||||
std::lock_guard<std::recursive_mutex> enumlock{EnumerationLock};
|
||||
if(DevicesList.Names.empty())
|
||||
(void)alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
|
||||
std::ignore = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
|
||||
idx = GetDriverIndexForName(&DevicesList, devicename);
|
||||
if(idx < 0)
|
||||
{
|
||||
if(AllDevicesList.Names.empty())
|
||||
(void)alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
|
||||
std::ignore = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
|
||||
idx = GetDriverIndexForName(&AllDevicesList, devicename);
|
||||
}
|
||||
}
|
||||
@@ -345,17 +431,17 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
|
||||
return nullptr;
|
||||
}
|
||||
TRACE("Found driver %d for name \"%s\"\n", idx, devicename);
|
||||
device = DriverList[idx].alcOpenDevice(devicename);
|
||||
device = DriverList[idx]->alcOpenDevice(devicename);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(const auto &drv : DriverList)
|
||||
{
|
||||
if(drv.ALCVer >= MAKE_ALC_VER(1, 1) ||
|
||||
drv.alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
|
||||
if(drv->ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv->alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
|
||||
{
|
||||
TRACE("Using default device from driver %d\n", idx);
|
||||
device = drv.alcOpenDevice(nullptr);
|
||||
device = drv->alcOpenDevice(nullptr);
|
||||
break;
|
||||
}
|
||||
++idx;
|
||||
@@ -366,7 +452,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
|
||||
{
|
||||
if(DeviceIfaceMap.insert(device, idx) != ALC_NO_ERROR)
|
||||
{
|
||||
DriverList[idx].alcCloseDevice(device);
|
||||
DriverList[idx]->alcCloseDevice(device);
|
||||
device = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -374,7 +460,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;
|
||||
|
||||
@@ -383,14 +469,14 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device)
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
if(!DriverList[idx].alcCloseDevice(device))
|
||||
if(!DriverList[idx]->alcCloseDevice(device))
|
||||
return ALC_FALSE;
|
||||
DeviceIfaceMap.removeByKey(device);
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@@ -400,12 +486,12 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return nullptr;
|
||||
}
|
||||
context = DriverList[idx].alcCreateContext(device, attrlist);
|
||||
context = DriverList[idx]->alcCreateContext(device, attrlist);
|
||||
if(context)
|
||||
{
|
||||
if(ContextIfaceMap.insert(context, idx) != ALC_NO_ERROR)
|
||||
{
|
||||
DriverList[idx].alcDestroyContext(context);
|
||||
DriverList[idx]->alcDestroyContext(context);
|
||||
context = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -413,11 +499,11 @@ 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;
|
||||
|
||||
std::lock_guard<std::mutex> _{ContextSwitchLock};
|
||||
std::lock_guard<std::mutex> ctxlock{ContextSwitchLock};
|
||||
if(context)
|
||||
{
|
||||
idx = ContextIfaceMap.lookupByKey(context);
|
||||
@@ -426,8 +512,11 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
|
||||
LastError.store(ALC_INVALID_CONTEXT);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
if(!DriverList[idx].alcMakeContextCurrent(context))
|
||||
if(!DriverList[idx]->alcMakeContextCurrent(context))
|
||||
return ALC_FALSE;
|
||||
|
||||
auto do_init = [idx]() { InitCtxFuncs(*DriverList[idx]); };
|
||||
std::call_once(DriverList[idx]->InitOnceCtx, do_init);
|
||||
}
|
||||
|
||||
/* Unset the context from the old driver if it's different from the new
|
||||
@@ -443,10 +532,10 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
|
||||
else
|
||||
{
|
||||
DriverIface *oldiface = GetThreadDriver();
|
||||
if(oldiface && oldiface != &DriverList[idx])
|
||||
if(oldiface && oldiface != DriverList[idx].get())
|
||||
oldiface->alcSetThreadContext(nullptr);
|
||||
oldiface = CurrentCtxDriver.exchange(&DriverList[idx]);
|
||||
if(oldiface && oldiface != &DriverList[idx])
|
||||
oldiface = CurrentCtxDriver.exchange(DriverList[idx].get());
|
||||
if(oldiface && oldiface != DriverList[idx].get())
|
||||
oldiface->alcMakeContextCurrent(nullptr);
|
||||
}
|
||||
SetThreadDriver(nullptr);
|
||||
@@ -454,29 +543,29 @@ 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)
|
||||
{
|
||||
ALint idx = ContextIfaceMap.lookupByKey(context);
|
||||
if(idx >= 0)
|
||||
return DriverList[idx].alcProcessContext(context);
|
||||
return DriverList[idx]->alcProcessContext(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)
|
||||
{
|
||||
ALint idx = ContextIfaceMap.lookupByKey(context);
|
||||
if(idx >= 0)
|
||||
return DriverList[idx].alcSuspendContext(context);
|
||||
return DriverList[idx]->alcSuspendContext(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;
|
||||
|
||||
@@ -486,42 +575,42 @@ ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
||||
return;
|
||||
}
|
||||
|
||||
DriverList[idx].alcDestroyContext(context);
|
||||
DriverList[idx]->alcDestroyContext(context);
|
||||
ContextIfaceMap.removeByKey(context);
|
||||
}
|
||||
|
||||
ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
|
||||
ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext() 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)
|
||||
{
|
||||
ALint idx = ContextIfaceMap.lookupByKey(context);
|
||||
if(idx >= 0)
|
||||
return DriverList[idx].alcGetContextsDevice(context);
|
||||
return DriverList[idx]->alcGetContextsDevice(context);
|
||||
}
|
||||
LastError.store(ALC_INVALID_CONTEXT);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device)
|
||||
ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) noexcept
|
||||
{
|
||||
if(device)
|
||||
{
|
||||
ALint idx = DeviceIfaceMap.lookupByKey(device);
|
||||
if(idx < 0) return ALC_INVALID_DEVICE;
|
||||
return DriverList[idx].alcGetError(device);
|
||||
return DriverList[idx]->alcGetError(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;
|
||||
@@ -534,7 +623,7 @@ ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const A
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
return DriverList[idx].alcIsExtensionPresent(device, extname);
|
||||
return DriverList[idx]->alcIsExtensionPresent(device, extname);
|
||||
}
|
||||
|
||||
len = strlen(extname);
|
||||
@@ -553,7 +642,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)
|
||||
{
|
||||
@@ -563,7 +652,7 @@ ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *f
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return nullptr;
|
||||
}
|
||||
return DriverList[idx].alcGetProcAddress(device, funcname);
|
||||
return DriverList[idx]->alcGetProcAddress(device, funcname);
|
||||
}
|
||||
|
||||
auto iter = std::find_if(alcFunctions.cbegin(), alcFunctions.cend(),
|
||||
@@ -573,7 +662,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)
|
||||
{
|
||||
@@ -583,7 +672,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *e
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return 0;
|
||||
}
|
||||
return DriverList[idx].alcGetEnumValue(device, enumname);
|
||||
return DriverList[idx]->alcGetEnumValue(device, enumname);
|
||||
}
|
||||
|
||||
auto iter = std::find_if(alcEnumerations.cbegin(), alcEnumerations.cend(),
|
||||
@@ -593,7 +682,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)
|
||||
{
|
||||
@@ -603,7 +692,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return nullptr;
|
||||
}
|
||||
return DriverList[idx].alcGetString(device, param);
|
||||
return DriverList[idx]->alcGetString(device, param);
|
||||
}
|
||||
|
||||
switch(param)
|
||||
@@ -625,16 +714,16 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
|
||||
|
||||
case ALC_DEVICE_SPECIFIER:
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _{EnumerationLock};
|
||||
std::lock_guard<std::recursive_mutex> enumlock{EnumerationLock};
|
||||
DevicesList.clear();
|
||||
ALint idx{0};
|
||||
for(const auto &drv : DriverList)
|
||||
{
|
||||
/* Only enumerate names from drivers that support it. */
|
||||
if(drv.ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv.alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
|
||||
if(drv->ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv->alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
|
||||
AppendDeviceList(&DevicesList,
|
||||
drv.alcGetString(nullptr, ALC_DEVICE_SPECIFIER), idx);
|
||||
drv->alcGetString(nullptr, ALC_DEVICE_SPECIFIER), idx);
|
||||
++idx;
|
||||
}
|
||||
/* Ensure the list is double-null termianted. */
|
||||
@@ -646,7 +735,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
|
||||
|
||||
case ALC_ALL_DEVICES_SPECIFIER:
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _{EnumerationLock};
|
||||
std::lock_guard<std::recursive_mutex> enumlock{EnumerationLock};
|
||||
AllDevicesList.clear();
|
||||
ALint idx{0};
|
||||
for(const auto &drv : DriverList)
|
||||
@@ -654,13 +743,13 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
|
||||
/* If the driver doesn't support ALC_ENUMERATE_ALL_EXT, substitute
|
||||
* standard enumeration.
|
||||
*/
|
||||
if(drv.alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT"))
|
||||
if(drv->alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT"))
|
||||
AppendDeviceList(&AllDevicesList,
|
||||
drv.alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER), idx);
|
||||
else if(drv.ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv.alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
|
||||
drv->alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER), idx);
|
||||
else if(drv->ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv->alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
|
||||
AppendDeviceList(&AllDevicesList,
|
||||
drv.alcGetString(nullptr, ALC_DEVICE_SPECIFIER), idx);
|
||||
drv->alcGetString(nullptr, ALC_DEVICE_SPECIFIER), idx);
|
||||
++idx;
|
||||
}
|
||||
/* Ensure the list is double-null termianted. */
|
||||
@@ -672,15 +761,15 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
|
||||
|
||||
case ALC_CAPTURE_DEVICE_SPECIFIER:
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _{EnumerationLock};
|
||||
std::lock_guard<std::recursive_mutex> enumlock{EnumerationLock};
|
||||
CaptureDevicesList.clear();
|
||||
ALint idx{0};
|
||||
for(const auto &drv : DriverList)
|
||||
{
|
||||
if(drv.ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv.alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE"))
|
||||
if(drv->ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv->alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE"))
|
||||
AppendDeviceList(&CaptureDevicesList,
|
||||
drv.alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER), idx);
|
||||
drv->alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER), idx);
|
||||
++idx;
|
||||
}
|
||||
/* Ensure the list is double-null termianted. */
|
||||
@@ -692,39 +781,33 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
|
||||
|
||||
case ALC_DEFAULT_DEVICE_SPECIFIER:
|
||||
{
|
||||
auto iter = std::find_if(DriverList.cbegin(), DriverList.cend(),
|
||||
[](const DriverIface &drv) -> bool
|
||||
{
|
||||
return drv.ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv.alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT");
|
||||
}
|
||||
);
|
||||
if(iter != DriverList.cend())
|
||||
return iter->alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
|
||||
for(const auto &drv : DriverList)
|
||||
{
|
||||
if(drv->ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv->alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
|
||||
return drv->alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
case ALC_DEFAULT_ALL_DEVICES_SPECIFIER:
|
||||
{
|
||||
auto iter = std::find_if(DriverList.cbegin(), DriverList.cend(),
|
||||
[](const DriverIface &drv) -> bool
|
||||
{ return drv.alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT") != ALC_FALSE; });
|
||||
if(iter != DriverList.cend())
|
||||
return iter->alcGetString(nullptr, ALC_DEFAULT_ALL_DEVICES_SPECIFIER);
|
||||
for(const auto &drv : DriverList)
|
||||
{
|
||||
if(drv->alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT") != ALC_FALSE)
|
||||
return drv->alcGetString(nullptr, ALC_DEFAULT_ALL_DEVICES_SPECIFIER);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER:
|
||||
{
|
||||
auto iter = std::find_if(DriverList.cbegin(), DriverList.cend(),
|
||||
[](const DriverIface &drv) -> bool
|
||||
{
|
||||
return drv.ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv.alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE");
|
||||
}
|
||||
);
|
||||
if(iter != DriverList.cend())
|
||||
return iter->alcGetString(nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
|
||||
for(const auto &drv : DriverList)
|
||||
{
|
||||
if(drv->ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv->alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE"))
|
||||
return drv->alcGetString(nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -735,7 +818,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)
|
||||
{
|
||||
@@ -745,7 +828,7 @@ ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsi
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return;
|
||||
}
|
||||
return DriverList[idx].alcGetIntegerv(device, param, size, values);
|
||||
return DriverList[idx]->alcGetIntegerv(device, param, size, values);
|
||||
}
|
||||
|
||||
if(size <= 0 || values == nullptr)
|
||||
@@ -790,7 +873,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;
|
||||
@@ -800,9 +883,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename,
|
||||
if(devicename)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _{EnumerationLock};
|
||||
std::lock_guard<std::recursive_mutex> enumlock{EnumerationLock};
|
||||
if(CaptureDevicesList.Names.empty())
|
||||
(void)alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER);
|
||||
std::ignore = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER);
|
||||
idx = GetDriverIndexForName(&CaptureDevicesList, devicename);
|
||||
}
|
||||
|
||||
@@ -813,17 +896,17 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename,
|
||||
return nullptr;
|
||||
}
|
||||
TRACE("Found driver %d for name \"%s\"\n", idx, devicename);
|
||||
device = DriverList[idx].alcCaptureOpenDevice(devicename, frequency, format, buffersize);
|
||||
device = DriverList[idx]->alcCaptureOpenDevice(devicename, frequency, format, buffersize);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(const auto &drv : DriverList)
|
||||
{
|
||||
if(drv.ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv.alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE"))
|
||||
if(drv->ALCVer >= MAKE_ALC_VER(1, 1)
|
||||
|| drv->alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE"))
|
||||
{
|
||||
TRACE("Using default capture device from driver %d\n", idx);
|
||||
device = drv.alcCaptureOpenDevice(nullptr, frequency, format, buffersize);
|
||||
device = drv->alcCaptureOpenDevice(nullptr, frequency, format, buffersize);
|
||||
break;
|
||||
}
|
||||
++idx;
|
||||
@@ -834,7 +917,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename,
|
||||
{
|
||||
if(DeviceIfaceMap.insert(device, idx) != ALC_NO_ERROR)
|
||||
{
|
||||
DriverList[idx].alcCaptureCloseDevice(device);
|
||||
DriverList[idx]->alcCaptureCloseDevice(device);
|
||||
device = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -842,7 +925,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;
|
||||
|
||||
@@ -851,47 +934,47 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device)
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
if(!DriverList[idx].alcCaptureCloseDevice(device))
|
||||
if(!DriverList[idx]->alcCaptureCloseDevice(device))
|
||||
return ALC_FALSE;
|
||||
DeviceIfaceMap.removeByKey(device);
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device)
|
||||
ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device) noexcept
|
||||
{
|
||||
if(device)
|
||||
{
|
||||
ALint idx = DeviceIfaceMap.lookupByKey(device);
|
||||
if(idx >= 0)
|
||||
return DriverList[idx].alcCaptureStart(device);
|
||||
return DriverList[idx]->alcCaptureStart(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)
|
||||
{
|
||||
ALint idx = DeviceIfaceMap.lookupByKey(device);
|
||||
if(idx >= 0)
|
||||
return DriverList[idx].alcCaptureStop(device);
|
||||
return DriverList[idx]->alcCaptureStop(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)
|
||||
{
|
||||
ALint idx = DeviceIfaceMap.lookupByKey(device);
|
||||
if(idx >= 0)
|
||||
return DriverList[idx].alcCaptureSamples(device, buffer, samples);
|
||||
return DriverList[idx]->alcCaptureSamples(device, buffer, samples);
|
||||
}
|
||||
LastError.store(ALC_INVALID_DEVICE);
|
||||
}
|
||||
|
||||
|
||||
ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
|
||||
ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) noexcept
|
||||
{
|
||||
ALCenum err = ALC_INVALID_CONTEXT;
|
||||
ALint idx;
|
||||
@@ -908,23 +991,26 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
|
||||
idx = ContextIfaceMap.lookupByKey(context);
|
||||
if(idx >= 0)
|
||||
{
|
||||
if(DriverList[idx].alcSetThreadContext(context))
|
||||
if(DriverList[idx]->alcSetThreadContext(context))
|
||||
{
|
||||
auto do_init = [idx]() { InitCtxFuncs(*DriverList[idx]); };
|
||||
std::call_once(DriverList[idx]->InitOnceCtx, do_init);
|
||||
|
||||
DriverIface *oldiface = GetThreadDriver();
|
||||
if(oldiface != &DriverList[idx])
|
||||
if(oldiface != DriverList[idx].get())
|
||||
{
|
||||
SetThreadDriver(&DriverList[idx]);
|
||||
SetThreadDriver(DriverList[idx].get());
|
||||
if(oldiface) oldiface->alcSetThreadContext(nullptr);
|
||||
}
|
||||
return ALC_TRUE;
|
||||
}
|
||||
err = DriverList[idx].alcGetError(nullptr);
|
||||
err = DriverList[idx]->alcGetError(nullptr);
|
||||
}
|
||||
LastError.store(err);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void)
|
||||
ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext() noexcept
|
||||
{
|
||||
DriverIface *iface = GetThreadDriver();
|
||||
if(iface) return iface->alcGetThreadContext();
|
||||
|
||||
Reference in New Issue
Block a user