update openal-soft to 1.24.3

keeping the alt 87514151c4 (diff-73a8dc1ce58605f6c5ea53548454c3bae516ec5132a29c9d7ff7edf9730c75be)
This commit is contained in:
AzaezelX 2025-09-03 11:09:27 -05:00
parent 12db0500e8
commit ba32094b7b
276 changed files with 49304 additions and 8712 deletions

View file

@ -51,9 +51,9 @@
#include "alnumeric.h"
#include "alspan.h"
#include "alstring.h"
#include "core/except.h"
#include "core/logging.h"
#include "direct_defs.h"
#include "error.h"
#include "intrusive_ptr.h"
#include "opthelpers.h"
@ -139,7 +139,8 @@ void InitEffectParams(ALeffect *effect, ALenum type) noexcept
effect->type = type;
}
auto EnsureEffects(ALCdevice *device, size_t needed) noexcept -> bool
[[nodiscard]]
auto EnsureEffects(al::Device *device, size_t needed) noexcept -> bool
try {
size_t count{std::accumulate(device->EffectList.cbegin(), device->EffectList.cend(), 0_uz,
[](size_t cur, const EffectSubList &sublist) noexcept -> size_t
@ -162,7 +163,8 @@ catch(...) {
return false;
}
ALeffect *AllocEffect(ALCdevice *device) noexcept
[[nodiscard]]
auto AllocEffect(al::Device *device) noexcept -> ALeffect*
{
auto sublist = std::find_if(device->EffectList.begin(), device->EffectList.end(),
[](const EffectSubList &entry) noexcept -> bool
@ -182,7 +184,7 @@ ALeffect *AllocEffect(ALCdevice *device) noexcept
return effect;
}
void FreeEffect(ALCdevice *device, ALeffect *effect)
void FreeEffect(al::Device *device, ALeffect *effect)
{
device->mEffectNames.erase(effect->id);
@ -195,7 +197,8 @@ void FreeEffect(ALCdevice *device, ALeffect *effect)
device->EffectList[lidx].FreeMask |= 1_u64 << slidx;
}
inline auto LookupEffect(ALCdevice *device, ALuint id) noexcept -> ALeffect*
[[nodiscard]] inline
auto LookupEffect(al::Device *device, ALuint id) noexcept -> ALeffect*
{
const size_t lidx{(id-1) >> 6};
const ALuint slidx{(id-1) & 0x3f};
@ -214,21 +217,23 @@ AL_API DECL_FUNC2(void, alGenEffects, ALsizei,n, ALuint*,effects)
FORCE_ALIGN void AL_APIENTRY alGenEffectsDirect(ALCcontext *context, ALsizei n, ALuint *effects) noexcept
try {
if(n < 0)
throw al::context_error{AL_INVALID_VALUE, "Generating %d effects", n};
context->throw_error(AL_INVALID_VALUE, "Generating {} effects", n);
if(n <= 0) UNLIKELY return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
const al::span eids{effects, static_cast<ALuint>(n)};
if(!EnsureEffects(device, eids.size()))
throw al::context_error{AL_OUT_OF_MEMORY, "Failed to allocate %d effect%s", n,
(n == 1) ? "" : "s"};
context->throw_error(AL_OUT_OF_MEMORY, "Failed to allocate {} effect{}", n,
(n==1) ? "" : "s");
std::generate(eids.begin(), eids.end(), [device]{ return AllocEffect(device)->id; });
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC2(void, alDeleteEffects, ALsizei,n, const ALuint*,effects)
@ -236,11 +241,11 @@ FORCE_ALIGN void AL_APIENTRY alDeleteEffectsDirect(ALCcontext *context, ALsizei
const ALuint *effects) noexcept
try {
if(n < 0)
throw al::context_error{AL_INVALID_VALUE, "Deleting %d effects", n};
context->throw_error(AL_INVALID_VALUE, "Deleting {} effects", n);
if(n <= 0) UNLIKELY return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
/* First try to find any effects that are invalid. */
auto validate_effect = [device](const ALuint eid) -> bool
@ -249,7 +254,7 @@ try {
const al::span eids{effects, static_cast<ALuint>(n)};
auto inveffect = std::find_if_not(eids.begin(), eids.end(), validate_effect);
if(inveffect != eids.end())
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", *inveffect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", *inveffect);
/* All good. Delete non-0 effect IDs. */
auto delete_effect = [device](ALuint eid) -> void
@ -259,15 +264,17 @@ try {
};
std::for_each(eids.begin(), eids.end(), delete_effect);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC1(ALboolean, alIsEffect, ALuint,effect)
FORCE_ALIGN ALboolean AL_APIENTRY alIsEffectDirect(ALCcontext *context, ALuint effect) noexcept
{
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
if(!effect || LookupEffect(device, effect))
return AL_TRUE;
return AL_FALSE;
@ -277,12 +284,12 @@ AL_API DECL_FUNC3(void, alEffecti, ALuint,effect, ALenum,param, ALint,value)
FORCE_ALIGN void AL_APIENTRY alEffectiDirect(ALCcontext *context, ALuint effect, ALenum param,
ALint value) noexcept
try {
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
switch(param)
{
@ -292,8 +299,8 @@ try {
auto check_effect = [value](const EffectList &item) -> bool
{ return value == item.val && !DisabledEffects.test(item.type); };
if(!std::any_of(gEffectList.cbegin(), gEffectList.cend(), check_effect))
throw al::context_error{AL_INVALID_VALUE, "Effect type 0x%04x not supported",
value};
context->throw_error(AL_INVALID_VALUE, "Effect type {:#04x} not supported",
as_unsigned(value));
}
InitEffectParams(aleffect, value);
@ -301,15 +308,17 @@ try {
}
/* Call the appropriate handler */
std::visit([aleffect,param,value](auto &arg)
std::visit([context,aleffect,param,value](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.SetParami(std::get<PropType>(aleffect->Props), param, value);
return arg.SetParami(context, std::get<PropType>(aleffect->Props), param, value);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC3(void, alEffectiv, ALuint,effect, ALenum,param, const ALint*,values)
@ -323,81 +332,87 @@ try {
return;
}
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
/* Call the appropriate handler */
std::visit([aleffect,param,values](auto &arg)
std::visit([context,aleffect,param,values](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.SetParamiv(std::get<PropType>(aleffect->Props), param, values);
return arg.SetParamiv(context, std::get<PropType>(aleffect->Props), param, values);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC3(void, alEffectf, ALuint,effect, ALenum,param, ALfloat,value)
FORCE_ALIGN void AL_APIENTRY alEffectfDirect(ALCcontext *context, ALuint effect, ALenum param,
ALfloat value) noexcept
try {
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect) UNLIKELY
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
if(!aleffect)
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
/* Call the appropriate handler */
std::visit([aleffect,param,value](auto &arg)
std::visit([context,aleffect,param,value](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.SetParamf(std::get<PropType>(aleffect->Props), param, value);
return arg.SetParamf(context, std::get<PropType>(aleffect->Props), param, value);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC3(void, alEffectfv, ALuint,effect, ALenum,param, const ALfloat*,values)
FORCE_ALIGN void AL_APIENTRY alEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param,
const ALfloat *values) noexcept
try {
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
/* Call the appropriate handler */
std::visit([aleffect,param,values](auto &arg)
std::visit([context,aleffect,param,values](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.SetParamfv(std::get<PropType>(aleffect->Props), param, values);
return arg.SetParamfv(context, std::get<PropType>(aleffect->Props), param, values);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC3(void, alGetEffecti, ALuint,effect, ALenum,param, ALint*,value)
FORCE_ALIGN void AL_APIENTRY alGetEffectiDirect(ALCcontext *context, ALuint effect, ALenum param,
ALint *value) noexcept
try {
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
switch(param)
{
@ -407,15 +422,17 @@ try {
}
/* Call the appropriate handler */
std::visit([aleffect,param,value](auto &arg)
std::visit([context,aleffect,param,value](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.GetParami(std::get<PropType>(aleffect->Props), param, value);
return arg.GetParami(context, std::get<PropType>(aleffect->Props), param, value);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC3(void, alGetEffectiv, ALuint,effect, ALenum,param, ALint*,values)
@ -429,69 +446,75 @@ try {
return;
}
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
/* Call the appropriate handler */
std::visit([aleffect,param,values](auto &arg)
std::visit([context,aleffect,param,values](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.GetParamiv(std::get<PropType>(aleffect->Props), param, values);
return arg.GetParamiv(context, std::get<PropType>(aleffect->Props), param, values);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC3(void, alGetEffectf, ALuint,effect, ALenum,param, ALfloat*,value)
FORCE_ALIGN void AL_APIENTRY alGetEffectfDirect(ALCcontext *context, ALuint effect, ALenum param,
ALfloat *value) noexcept
try {
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
/* Call the appropriate handler */
std::visit([aleffect,param,value](auto &arg)
std::visit([context,aleffect,param,value](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.GetParamf(std::get<PropType>(aleffect->Props), param, value);
return arg.GetParamf(context, std::get<PropType>(aleffect->Props), param, value);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
AL_API DECL_FUNC3(void, alGetEffectfv, ALuint,effect, ALenum,param, ALfloat*,values)
FORCE_ALIGN void AL_APIENTRY alGetEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param,
ALfloat *values) noexcept
try {
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
if(!aleffect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", effect};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", effect);
/* Call the appropriate handler */
std::visit([aleffect,param,values](auto &arg)
std::visit([context,aleffect,param,values](auto &arg)
{
using Type = std::remove_cv_t<std::remove_reference_t<decltype(arg)>>;
using PropType = typename Type::prop_type;
return arg.GetParamfv(std::get<PropType>(aleffect->Props), param, values);
return arg.GetParamfv(context, std::get<PropType>(aleffect->Props), param, values);
}, aleffect->PropsVariant);
}
catch(al::context_error& e) {
context->setError(e.errorCode(), "%s", e.what());
catch(al::base_exception&) {
}
catch(std::exception &e) {
ERR("Caught exception: {}", e.what());
}
@ -502,12 +525,12 @@ void InitEffect(ALeffect *effect)
void ALeffect::SetName(ALCcontext* context, ALuint id, std::string_view name)
{
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
auto effect = LookupEffect(device, id);
if(!effect)
throw al::context_error{AL_INVALID_NAME, "Invalid effect ID %u", id};
context->throw_error(AL_INVALID_NAME, "Invalid effect ID {}", id);
device->mEffectNames.insert_or_assign(id, name);
}
@ -673,7 +696,7 @@ void LoadReverbPreset(const std::string_view name, ALeffect *effect)
if(al::case_compare(name, "NONE"sv) == 0)
{
InitEffectParams(effect, AL_EFFECT_NULL);
TRACE("Loading reverb '%s'\n", "NONE");
TRACE("Loading reverb '{}'", "NONE");
return;
}
@ -688,7 +711,7 @@ void LoadReverbPreset(const std::string_view name, ALeffect *effect)
if(al::case_compare(name, std::data(reverbitem.name)) != 0)
continue;
TRACE("Loading reverb '%s'\n", std::data(reverbitem.name));
TRACE("Loading reverb '{}'", std::data(reverbitem.name));
const auto &props = reverbitem.props;
auto &dst = std::get<ReverbProps>(effect->Props);
dst.Density = props.flDensity;
@ -721,7 +744,7 @@ void LoadReverbPreset(const std::string_view name, ALeffect *effect)
return;
}
WARN("Reverb preset '%.*s' not found\n", al::sizei(name), name.data());
WARN("Reverb preset '{}' not found", name);
}
bool IsValidEffectType(ALenum type) noexcept