null.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #include "config.h"
  2. #include "AL/al.h"
  3. #include "AL/efx.h"
  4. #include "alc/context.h"
  5. #include "alnumeric.h"
  6. #include "effects.h"
  7. #if ALSOFT_EAX
  8. #include "al/eax/effect.h"
  9. #include "al/eax/exception.h"
  10. #endif // ALSOFT_EAX
  11. namespace {
  12. constexpr EffectProps genDefaultProps() noexcept
  13. {
  14. return std::monostate{};
  15. }
  16. } // namespace
  17. const EffectProps NullEffectProps{genDefaultProps()};
  18. void NullEffectHandler::SetParami(ALCcontext *context, std::monostate& /*props*/, ALenum param, int /*val*/)
  19. {
  20. context->throw_error(AL_INVALID_ENUM, "Invalid null effect integer property {:#04x}",
  21. as_unsigned(param));
  22. }
  23. void NullEffectHandler::SetParamiv(ALCcontext *context, std::monostate &props, ALenum param, const int *vals)
  24. {
  25. SetParami(context, props, param, *vals);
  26. }
  27. void NullEffectHandler::SetParamf(ALCcontext *context, std::monostate& /*props*/, ALenum param, float /*val*/)
  28. {
  29. context->throw_error(AL_INVALID_ENUM, "Invalid null effect float property {:#04x}",
  30. as_unsigned(param));
  31. }
  32. void NullEffectHandler::SetParamfv(ALCcontext *context, std::monostate &props, ALenum param, const float *vals)
  33. {
  34. SetParamf(context, props, param, *vals);
  35. }
  36. void NullEffectHandler::GetParami(ALCcontext *context, const std::monostate& /*props*/, ALenum param, int* /*val*/)
  37. {
  38. context->throw_error(AL_INVALID_ENUM, "Invalid null effect integer property {:#04x}",
  39. as_unsigned(param));
  40. }
  41. void NullEffectHandler::GetParamiv(ALCcontext *context, const std::monostate &props, ALenum param, int *vals)
  42. {
  43. GetParami(context, props, param, vals);
  44. }
  45. void NullEffectHandler::GetParamf(ALCcontext *context, const std::monostate& /*props*/, ALenum param, float* /*val*/)
  46. {
  47. context->throw_error(AL_INVALID_ENUM, "Invalid null effect float property {:#04x}",
  48. as_unsigned(param));
  49. }
  50. void NullEffectHandler::GetParamfv(ALCcontext *context, const std::monostate &props, ALenum param, float *vals)
  51. {
  52. GetParamf(context, props, param, vals);
  53. }
  54. #if ALSOFT_EAX
  55. namespace {
  56. using NullCommitter = EaxCommitter<EaxNullCommitter>;
  57. } // namespace
  58. template<>
  59. struct NullCommitter::Exception : public EaxException
  60. {
  61. explicit Exception(const char *message) : EaxException{"EAX_NULL_EFFECT", message}
  62. { }
  63. };
  64. template<>
  65. [[noreturn]] void NullCommitter::fail(const char *message)
  66. {
  67. throw Exception{message};
  68. }
  69. bool EaxNullCommitter::commit(const std::monostate &props)
  70. {
  71. const bool ret{std::holds_alternative<std::monostate>(mEaxProps)};
  72. mEaxProps = props;
  73. mAlProps = std::monostate{};
  74. return ret;
  75. }
  76. void EaxNullCommitter::SetDefaults(EaxEffectProps &props)
  77. {
  78. props = std::monostate{};
  79. }
  80. void EaxNullCommitter::Get(const EaxCall &call, const std::monostate&)
  81. {
  82. if(call.get_property_id() != 0)
  83. fail_unknown_property_id();
  84. }
  85. void EaxNullCommitter::Set(const EaxCall &call, std::monostate&)
  86. {
  87. if(call.get_property_id() != 0)
  88. fail_unknown_property_id();
  89. }
  90. #endif // ALSOFT_EAX