null.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "config.h"
  2. #include "alcmain.h"
  3. #include "alcontext.h"
  4. #include "almalloc.h"
  5. #include "alspan.h"
  6. #include "effects/base.h"
  7. #include "effectslot.h"
  8. namespace {
  9. struct NullState final : public EffectState {
  10. NullState();
  11. ~NullState() override;
  12. void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
  13. void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
  14. const EffectTarget target) override;
  15. void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
  16. const al::span<FloatBufferLine> samplesOut) override;
  17. DEF_NEWDEL(NullState)
  18. };
  19. /* This constructs the effect state. It's called when the object is first
  20. * created.
  21. */
  22. NullState::NullState() = default;
  23. /* This destructs the effect state. It's called only when the effect instance
  24. * is no longer used.
  25. */
  26. NullState::~NullState() = default;
  27. /* This updates the device-dependant effect state. This is called on state
  28. * initialization and any time the device parameters (e.g. playback frequency,
  29. * format) have been changed. Will always be followed by a call to the update
  30. * method, if successful.
  31. */
  32. void NullState::deviceUpdate(const ALCdevice* /*device*/, const Buffer& /*buffer*/)
  33. {
  34. }
  35. /* This updates the effect state with new properties. This is called any time
  36. * the effect is (re)loaded into a slot.
  37. */
  38. void NullState::update(const ALCcontext* /*context*/, const EffectSlot* /*slot*/,
  39. const EffectProps* /*props*/, const EffectTarget /*target*/)
  40. {
  41. }
  42. /* This processes the effect state, for the given number of samples from the
  43. * input to the output buffer. The result should be added to the output buffer,
  44. * not replace it.
  45. */
  46. void NullState::process(const size_t/*samplesToDo*/,
  47. const al::span<const FloatBufferLine> /*samplesIn*/,
  48. const al::span<FloatBufferLine> /*samplesOut*/)
  49. {
  50. }
  51. struct NullStateFactory final : public EffectStateFactory {
  52. al::intrusive_ptr<EffectState> create() override;
  53. };
  54. /* Creates EffectState objects of the appropriate type. */
  55. al::intrusive_ptr<EffectState> NullStateFactory::create()
  56. { return al::intrusive_ptr<EffectState>{new NullState{}}; }
  57. } // namespace
  58. EffectStateFactory *NullStateFactory_getFactory()
  59. {
  60. static NullStateFactory NullFactory{};
  61. return &NullFactory;
  62. }