null.cpp 2.4 KB

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