null.cpp 3.0 KB

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