]> git.tdb.fi Git - ext/openal.git/blob - alc/effects/null.cpp
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / alc / effects / null.cpp
1
2 #include "config.h"
3
4 #include <stddef.h>
5
6 #include "almalloc.h"
7 #include "alspan.h"
8 #include "base.h"
9 #include "core/bufferline.h"
10 #include "intrusive_ptr.h"
11
12 struct ContextBase;
13 struct DeviceBase;
14 struct EffectSlot;
15
16
17 namespace {
18
19 struct NullState final : public EffectState {
20     NullState();
21     ~NullState() override;
22
23     void deviceUpdate(const DeviceBase *device, const BufferStorage *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;
28
29     DEF_NEWDEL(NullState)
30 };
31
32 /* This constructs the effect state. It's called when the object is first
33  * created.
34  */
35 NullState::NullState() = default;
36
37 /* This destructs the effect state. It's called only when the effect instance
38  * is no longer used.
39  */
40 NullState::~NullState() = default;
41
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.
46  */
47 void NullState::deviceUpdate(const DeviceBase* /*device*/, const BufferStorage* /*buffer*/)
48 {
49 }
50
51 /* This updates the effect state with new properties. This is called any time
52  * the effect is (re)loaded into a slot.
53  */
54 void NullState::update(const ContextBase* /*context*/, const EffectSlot* /*slot*/,
55     const EffectProps* /*props*/, const EffectTarget /*target*/)
56 {
57 }
58
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.
62  */
63 void NullState::process(const size_t/*samplesToDo*/,
64     const al::span<const FloatBufferLine> /*samplesIn*/,
65     const al::span<FloatBufferLine> /*samplesOut*/)
66 {
67 }
68
69
70 struct NullStateFactory final : public EffectStateFactory {
71     al::intrusive_ptr<EffectState> create() override;
72 };
73
74 /* Creates EffectState objects of the appropriate type. */
75 al::intrusive_ptr<EffectState> NullStateFactory::create()
76 { return al::intrusive_ptr<EffectState>{new NullState{}}; }
77
78 } // namespace
79
80 EffectStateFactory *NullStateFactory_getFactory()
81 {
82     static NullStateFactory NullFactory{};
83     return &NullFactory;
84 }