Move some temp variables closer to where they're used
[openal-soft.git] / alc / effects / null.cpp
blobcda1420ee683d474e841d1e8fac9dc8113237bb7
2 #include "config.h"
4 #include <stddef.h>
6 #include "almalloc.h"
7 #include "alspan.h"
8 #include "base.h"
9 #include "core/bufferline.h"
10 #include "intrusive_ptr.h"
12 struct ContextBase;
13 struct DeviceBase;
14 struct EffectSlot;
17 namespace {
19 struct NullState final : public EffectState {
20 NullState();
21 ~NullState() override;
23 void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
24 void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
25 const EffectTarget target) override;
26 void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
27 const al::span<FloatBufferLine> samplesOut) override;
29 DEF_NEWDEL(NullState)
32 /* This constructs the effect state. It's called when the object is first
33 * created.
35 NullState::NullState() = default;
37 /* This destructs the effect state. It's called only when the effect instance
38 * is no longer used.
40 NullState::~NullState() = default;
42 /* This updates the device-dependant effect state. This is called on state
43 * initialization and any time the device parameters (e.g. playback frequency,
44 * format) have been changed. Will always be followed by a call to the update
45 * method, if successful.
47 void NullState::deviceUpdate(const DeviceBase* /*device*/, const Buffer& /*buffer*/)
51 /* This updates the effect state with new properties. This is called any time
52 * the effect is (re)loaded into a slot.
54 void NullState::update(const ContextBase* /*context*/, const EffectSlot* /*slot*/,
55 const EffectProps* /*props*/, const EffectTarget /*target*/)
59 /* This processes the effect state, for the given number of samples from the
60 * input to the output buffer. The result should be added to the output buffer,
61 * not replace it.
63 void NullState::process(const size_t/*samplesToDo*/,
64 const al::span<const FloatBufferLine> /*samplesIn*/,
65 const al::span<FloatBufferLine> /*samplesOut*/)
70 struct NullStateFactory final : public EffectStateFactory {
71 al::intrusive_ptr<EffectState> create() override;
74 /* Creates EffectState objects of the appropriate type. */
75 al::intrusive_ptr<EffectState> NullStateFactory::create()
76 { return al::intrusive_ptr<EffectState>{new NullState{}}; }
78 } // namespace
80 EffectStateFactory *NullStateFactory_getFactory()
82 static NullStateFactory NullFactory{};
83 return &NullFactory;