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

161 lines
4.6 KiB

  1. #include "config.h"
  2. #include <cstdlib>
  3. #include "AL/al.h"
  4. #include "AL/alc.h"
  5. #include "alMain.h"
  6. #include "alcontext.h"
  7. #include "alAuxEffectSlot.h"
  8. #include "alError.h"
  9. namespace {
  10. struct NullState final : public EffectState {
  11. NullState();
  12. ~NullState() override;
  13. ALboolean deviceUpdate(const ALCdevice *device) override;
  14. void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
  15. void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override;
  16. DEF_NEWDEL(NullState)
  17. };
  18. /* This constructs the effect state. It's called when the object is first
  19. * created.
  20. */
  21. NullState::NullState() = default;
  22. /* This destructs the effect state. It's called only when the effect instance
  23. * is no longer used.
  24. */
  25. NullState::~NullState() = default;
  26. /* This updates the device-dependant effect state. This is called on
  27. * initialization and any time the device parameters (e.g. playback frequency,
  28. * format) have been changed. Will always be followed by a call to the update
  29. * method, if successful.
  30. */
  31. ALboolean NullState::deviceUpdate(const ALCdevice* UNUSED(device))
  32. {
  33. return AL_TRUE;
  34. }
  35. /* This updates the effect state. This is called any time the effect is
  36. * (re)loaded into a slot.
  37. */
  38. void NullState::update(const ALCcontext* UNUSED(context), const ALeffectslot* UNUSED(slot), const EffectProps* UNUSED(props), const EffectTarget UNUSED(target))
  39. {
  40. }
  41. /* This processes the effect state, for the given number of samples from the
  42. * input to the output buffer. The result should be added to the output buffer,
  43. * not replace it.
  44. */
  45. void NullState::process(ALsizei /*samplesToDo*/, const ALfloat (*RESTRICT /*samplesIn*/)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT /*samplesOut*/)[BUFFERSIZE], const ALsizei /*numOutput*/)
  46. {
  47. }
  48. void NullEffect_setParami(EffectProps *UNUSED(props), ALCcontext *context, ALenum param, ALint UNUSED(val))
  49. {
  50. switch(param)
  51. {
  52. default:
  53. alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", param);
  54. }
  55. }
  56. void NullEffect_setParamiv(EffectProps *props, ALCcontext *context, ALenum param, const ALint *vals)
  57. {
  58. switch(param)
  59. {
  60. default:
  61. NullEffect_setParami(props, context, param, vals[0]);
  62. }
  63. }
  64. void NullEffect_setParamf(EffectProps *UNUSED(props), ALCcontext *context, ALenum param, ALfloat UNUSED(val))
  65. {
  66. switch(param)
  67. {
  68. default:
  69. alSetError(context, AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", param);
  70. }
  71. }
  72. void NullEffect_setParamfv(EffectProps *props, ALCcontext *context, ALenum param, const ALfloat *vals)
  73. {
  74. switch(param)
  75. {
  76. default:
  77. NullEffect_setParamf(props, context, param, vals[0]);
  78. }
  79. }
  80. void NullEffect_getParami(const EffectProps *UNUSED(props), ALCcontext *context, ALenum param, ALint* UNUSED(val))
  81. {
  82. switch(param)
  83. {
  84. default:
  85. alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", param);
  86. }
  87. }
  88. void NullEffect_getParamiv(const EffectProps *props, ALCcontext *context, ALenum param, ALint *vals)
  89. {
  90. switch(param)
  91. {
  92. default:
  93. NullEffect_getParami(props, context, param, vals);
  94. }
  95. }
  96. void NullEffect_getParamf(const EffectProps *UNUSED(props), ALCcontext *context, ALenum param, ALfloat* UNUSED(val))
  97. {
  98. switch(param)
  99. {
  100. default:
  101. alSetError(context, AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", param);
  102. }
  103. }
  104. void NullEffect_getParamfv(const EffectProps *props, ALCcontext *context, ALenum param, ALfloat *vals)
  105. {
  106. switch(param)
  107. {
  108. default:
  109. NullEffect_getParamf(props, context, param, vals);
  110. }
  111. }
  112. DEFINE_ALEFFECT_VTABLE(NullEffect);
  113. struct NullStateFactory final : public EffectStateFactory {
  114. EffectState *create() override;
  115. EffectProps getDefaultProps() const noexcept override;
  116. const EffectVtable *getEffectVtable() const noexcept override;
  117. };
  118. /* Creates EffectState objects of the appropriate type. */
  119. EffectState *NullStateFactory::create()
  120. { return new NullState{}; }
  121. /* Returns an ALeffectProps initialized with this effect type's default
  122. * property values.
  123. */
  124. EffectProps NullStateFactory::getDefaultProps() const noexcept
  125. {
  126. EffectProps props{};
  127. return props;
  128. }
  129. /* Returns a pointer to this effect type's global set/get vtable. */
  130. const EffectVtable *NullStateFactory::getEffectVtable() const noexcept
  131. { return &NullEffect_vtable; }
  132. } // namespace
  133. EffectStateFactory *NullStateFactory_getFactory()
  134. {
  135. static NullStateFactory NullFactory{};
  136. return &NullFactory;
  137. }