🛠️🐜 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.

152 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 :
  89. public EaxEffect
  90. {
  91. public:
  92. EaxNullEffect();
  93. void dispatch(const EaxEaxCall& eax_call) override;
  94. // [[nodiscard]]
  95. bool apply_deferred() override;
  96. }; // EaxNullEffect
  97. class EaxNullEffectException :
  98. public EaxException
  99. {
  100. public:
  101. explicit EaxNullEffectException(
  102. const char* message)
  103. :
  104. EaxException{"EAX_NULL_EFFECT", message}
  105. {
  106. }
  107. }; // EaxNullEffectException
  108. EaxNullEffect::EaxNullEffect()
  109. : EaxEffect{AL_EFFECT_NULL}
  110. {
  111. }
  112. void EaxNullEffect::dispatch(const EaxEaxCall& eax_call)
  113. {
  114. if(eax_call.get_property_id() != 0)
  115. throw EaxNullEffectException{"Unsupported property id."};
  116. }
  117. bool EaxNullEffect::apply_deferred()
  118. {
  119. return false;
  120. }
  121. } // namespace
  122. EaxEffectUPtr eax_create_eax_null_effect()
  123. {
  124. return std::make_unique<EaxNullEffect>();
  125. }
  126. #endif // ALSOFT_EAX