2021-01-26 19:01:35 +00:00
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include "AL/al.h"
|
|
|
|
|
#include "AL/efx.h"
|
|
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
#include "alc/context.h"
|
|
|
|
|
#include "alnumeric.h"
|
2021-01-26 19:01:35 +00:00
|
|
|
#include "effects.h"
|
2022-05-30 20:32:45 +00:00
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
#if ALSOFT_EAX
|
2024-06-30 19:35:57 +00:00
|
|
|
#include "al/eax/effect.h"
|
2024-03-21 17:33:47 +00:00
|
|
|
#include "al/eax/exception.h"
|
2022-05-30 20:32:45 +00:00
|
|
|
#endif // ALSOFT_EAX
|
2021-01-26 19:01:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
constexpr EffectProps genDefaultProps() noexcept
|
|
|
|
|
{
|
|
|
|
|
return std::monostate{};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
const EffectProps NullEffectProps{genDefaultProps()};
|
|
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::SetParami(ALCcontext *context, std::monostate& /*props*/, ALenum param, int /*val*/)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
context->throw_error(AL_INVALID_ENUM, "Invalid null effect integer property {:#04x}",
|
|
|
|
|
as_unsigned(param));
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::SetParamiv(ALCcontext *context, std::monostate &props, ALenum param, const int *vals)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
SetParami(context, props, param, *vals);
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::SetParamf(ALCcontext *context, std::monostate& /*props*/, ALenum param, float /*val*/)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
context->throw_error(AL_INVALID_ENUM, "Invalid null effect float property {:#04x}",
|
|
|
|
|
as_unsigned(param));
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::SetParamfv(ALCcontext *context, std::monostate &props, ALenum param, const float *vals)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
SetParamf(context, props, param, *vals);
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::GetParami(ALCcontext *context, const std::monostate& /*props*/, ALenum param, int* /*val*/)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
context->throw_error(AL_INVALID_ENUM, "Invalid null effect integer property {:#04x}",
|
|
|
|
|
as_unsigned(param));
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::GetParamiv(ALCcontext *context, const std::monostate &props, ALenum param, int *vals)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
GetParami(context, props, param, vals);
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::GetParamf(ALCcontext *context, const std::monostate& /*props*/, ALenum param, float* /*val*/)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
context->throw_error(AL_INVALID_ENUM, "Invalid null effect float property {:#04x}",
|
|
|
|
|
as_unsigned(param));
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
void NullEffectHandler::GetParamfv(ALCcontext *context, const std::monostate &props, ALenum param, float *vals)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2025-09-03 16:09:27 +00:00
|
|
|
GetParamf(context, props, param, vals);
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-30 20:32:45 +00:00
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
#if ALSOFT_EAX
|
2022-05-30 20:32:45 +00:00
|
|
|
namespace {
|
|
|
|
|
|
2024-03-21 17:33:47 +00:00
|
|
|
using NullCommitter = EaxCommitter<EaxNullCommitter>;
|
2022-05-30 20:32:45 +00:00
|
|
|
|
2024-03-21 17:33:47 +00:00
|
|
|
} // namespace
|
2022-05-30 20:32:45 +00:00
|
|
|
|
2024-03-21 17:33:47 +00:00
|
|
|
template<>
|
|
|
|
|
struct NullCommitter::Exception : public EaxException
|
2022-05-30 20:32:45 +00:00
|
|
|
{
|
2024-03-21 17:33:47 +00:00
|
|
|
explicit Exception(const char *message) : EaxException{"EAX_NULL_EFFECT", message}
|
|
|
|
|
{ }
|
|
|
|
|
};
|
2022-05-30 20:32:45 +00:00
|
|
|
|
2024-03-21 17:33:47 +00:00
|
|
|
template<>
|
|
|
|
|
[[noreturn]] void NullCommitter::fail(const char *message)
|
2022-05-30 20:32:45 +00:00
|
|
|
{
|
2024-03-21 17:33:47 +00:00
|
|
|
throw Exception{message};
|
2022-05-30 20:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
bool EaxNullCommitter::commit(const std::monostate &props)
|
2022-05-30 20:32:45 +00:00
|
|
|
{
|
2024-06-30 19:35:57 +00:00
|
|
|
const bool ret{std::holds_alternative<std::monostate>(mEaxProps)};
|
2024-03-21 17:33:47 +00:00
|
|
|
mEaxProps = props;
|
2024-06-30 19:35:57 +00:00
|
|
|
mAlProps = std::monostate{};
|
2024-03-21 17:33:47 +00:00
|
|
|
return ret;
|
2022-05-30 20:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
void EaxNullCommitter::SetDefaults(EaxEffectProps &props)
|
2022-05-30 20:32:45 +00:00
|
|
|
{
|
2024-06-30 19:35:57 +00:00
|
|
|
props = std::monostate{};
|
2022-05-30 20:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
void EaxNullCommitter::Get(const EaxCall &call, const std::monostate&)
|
2024-03-21 17:33:47 +00:00
|
|
|
{
|
|
|
|
|
if(call.get_property_id() != 0)
|
|
|
|
|
fail_unknown_property_id();
|
|
|
|
|
}
|
2022-05-30 20:32:45 +00:00
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
void EaxNullCommitter::Set(const EaxCall &call, std::monostate&)
|
2022-05-30 20:32:45 +00:00
|
|
|
{
|
2024-03-21 17:33:47 +00:00
|
|
|
if(call.get_property_id() != 0)
|
|
|
|
|
fail_unknown_property_id();
|
2022-05-30 20:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // ALSOFT_EAX
|