🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
2.8 KiB

  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/exception.h"
  8. #endif // ALSOFT_EAX
  9. namespace {
  10. void Null_setParami(EffectProps* /*props*/, ALenum param, int /*val*/)
  11. {
  12. switch(param)
  13. {
  14. default:
  15. throw effect_exception{AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x",
  16. param};
  17. }
  18. }
  19. void Null_setParamiv(EffectProps *props, ALenum param, const int *vals)
  20. {
  21. switch(param)
  22. {
  23. default:
  24. Null_setParami(props, param, vals[0]);
  25. }
  26. }
  27. void Null_setParamf(EffectProps* /*props*/, ALenum param, float /*val*/)
  28. {
  29. switch(param)
  30. {
  31. default:
  32. throw effect_exception{AL_INVALID_ENUM, "Invalid null effect float property 0x%04x",
  33. param};
  34. }
  35. }
  36. void Null_setParamfv(EffectProps *props, ALenum param, const float *vals)
  37. {
  38. switch(param)
  39. {
  40. default:
  41. Null_setParamf(props, param, vals[0]);
  42. }
  43. }
  44. void Null_getParami(const EffectProps* /*props*/, ALenum param, int* /*val*/)
  45. {
  46. switch(param)
  47. {
  48. default:
  49. throw effect_exception{AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x",
  50. param};
  51. }
  52. }
  53. void Null_getParamiv(const EffectProps *props, ALenum param, int *vals)
  54. {
  55. switch(param)
  56. {
  57. default:
  58. Null_getParami(props, param, vals);
  59. }
  60. }
  61. void Null_getParamf(const EffectProps* /*props*/, ALenum param, float* /*val*/)
  62. {
  63. switch(param)
  64. {
  65. default:
  66. throw effect_exception{AL_INVALID_ENUM, "Invalid null effect float property 0x%04x",
  67. param};
  68. }
  69. }
  70. void Null_getParamfv(const EffectProps *props, ALenum param, float *vals)
  71. {
  72. switch(param)
  73. {
  74. default:
  75. Null_getParamf(props, param, vals);
  76. }
  77. }
  78. EffectProps genDefaultProps() noexcept
  79. {
  80. EffectProps props{};
  81. return props;
  82. }
  83. } // namespace
  84. DEFINE_ALEFFECT_VTABLE(Null);
  85. const EffectProps NullEffectProps{genDefaultProps()};
  86. #ifdef ALSOFT_EAX
  87. namespace {
  88. class EaxNullEffect final : public EaxEffect {
  89. public:
  90. EaxNullEffect() noexcept;
  91. void dispatch(const EaxCall& call) override;
  92. /*[[nodiscard]]*/ bool commit() override;
  93. }; // EaxNullEffect
  94. class EaxNullEffectException : public EaxException
  95. {
  96. public:
  97. explicit EaxNullEffectException(const char* message)
  98. : EaxException{"EAX_NULL_EFFECT", message}
  99. {}
  100. }; // EaxNullEffectException
  101. EaxNullEffect::EaxNullEffect() noexcept
  102. : EaxEffect{AL_EFFECT_NULL}
  103. {}
  104. void EaxNullEffect::dispatch(const EaxCall& call)
  105. {
  106. if(call.get_property_id() != 0)
  107. throw EaxNullEffectException{"Unsupported property id."};
  108. }
  109. bool EaxNullEffect::commit()
  110. {
  111. return false;
  112. }
  113. } // namespace
  114. EaxEffectUPtr eax_create_eax_null_effect()
  115. {
  116. return std::make_unique<EaxNullEffect>();
  117. }
  118. #endif // ALSOFT_EAX