Skip to content

Commit

Permalink
Return an intrusive_ptr from EffectStateFactory::create
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Dec 28, 2020
1 parent 15e05fc commit aae115c
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 21 deletions.
3 changes: 1 addition & 2 deletions al/auxeffectslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,7 @@ ALenum ALeffectslot::init()
EffectStateFactory *factory{getFactoryByType(Effect.Type)};
if(!factory) return AL_INVALID_VALUE;

Effect.State.reset(factory->create());
if(!Effect.State) return AL_OUT_OF_MEMORY;
Effect.State = factory->create();

Effect.State->add_ref();
mSlot.mEffectState = Effect.State.get();
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/autowah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ void AutowahState::process(const size_t samplesToDo,


struct AutowahStateFactory final : public EffectStateFactory {
EffectState *create() override { return new AutowahState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new AutowahState{}}; }
};

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion alc/effects/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct EffectState : public al::intrusive_ref<EffectState> {
struct EffectStateFactory {
virtual ~EffectStateFactory() = default;

virtual EffectState *create() = 0;
virtual al::intrusive_ptr<EffectState> create() = 0;
};


Expand Down
6 changes: 4 additions & 2 deletions alc/effects/chorus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,17 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu


struct ChorusStateFactory final : public EffectStateFactory {
EffectState *create() override { return new ChorusState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new ChorusState{}}; }
};


/* Flanger is basically a chorus with a really short delay. They can both use
* the same processing functions, so piggyback flanger on the chorus functions.
*/
struct FlangerStateFactory final : public EffectStateFactory {
EffectState *create() override { return new ChorusState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new ChorusState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ void CompressorState::process(const size_t samplesToDo,


struct CompressorStateFactory final : public EffectStateFactory {
EffectState *create() override { return new CompressorState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new CompressorState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ void ConvolutionState::process(const size_t samplesToDo,


struct ConvolutionStateFactory final : public EffectStateFactory {
EffectState *create() override { return new ConvolutionState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new ConvolutionState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/dedicated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ void DedicatedState::process(const size_t samplesToDo, const al::span<const Floa


struct DedicatedStateFactory final : public EffectStateFactory {
EffectState *create() override { return new DedicatedState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new DedicatedState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/distortion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void DistortionState::process(const size_t samplesToDo, const al::span<const Flo


struct DistortionStateFactory final : public EffectStateFactory {
EffectState *create() override { return new DistortionState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new DistortionState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ void EchoState::process(const size_t samplesToDo, const al::span<const FloatBuff


struct EchoStateFactory final : public EffectStateFactory {
EffectState *create() override { return new EchoState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new EchoState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/equalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ void EqualizerState::process(const size_t samplesToDo, const al::span<const Floa


struct EqualizerStateFactory final : public EffectStateFactory {
EffectState *create() override { return new EqualizerState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new EqualizerState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/fshifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ void FshifterState::process(const size_t samplesToDo, const al::span<const Float


struct FshifterStateFactory final : public EffectStateFactory {
EffectState *create() override { return new FshifterState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new FshifterState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/modulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ void ModulatorState::process(const size_t samplesToDo, const al::span<const Floa


struct ModulatorStateFactory final : public EffectStateFactory {
EffectState *create() override { return new ModulatorState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new ModulatorState{}}; }
};

} // namespace
Expand Down
6 changes: 3 additions & 3 deletions alc/effects/null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ void NullState::process(const size_t/*samplesToDo*/,


struct NullStateFactory final : public EffectStateFactory {
EffectState *create() override;
al::intrusive_ptr<EffectState> create() override;
};

/* Creates EffectState objects of the appropriate type. */
EffectState *NullStateFactory::create()
{ return new NullState{}; }
al::intrusive_ptr<EffectState> NullStateFactory::create()
{ return al::intrusive_ptr<EffectState>{new NullState{}}; }

} // namespace

Expand Down
3 changes: 2 additions & 1 deletion alc/effects/pshifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float


struct PshifterStateFactory final : public EffectStateFactory {
EffectState *create() override { return new PshifterState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new PshifterState{}}; }
};

} // namespace
Expand Down
6 changes: 4 additions & 2 deletions alc/effects/reverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,11 +1680,13 @@ void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBu


struct ReverbStateFactory final : public EffectStateFactory {
EffectState *create() override { return new ReverbState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new ReverbState{}}; }
};

struct StdReverbStateFactory final : public EffectStateFactory {
EffectState *create() override { return new ReverbState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new ReverbState{}}; }
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion alc/effects/vmorpher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ void VmorpherState::process(const size_t samplesToDo, const al::span<const Float


struct VmorpherStateFactory final : public EffectStateFactory {
EffectState *create() override { return new VmorpherState{}; }
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new VmorpherState{}}; }
};

} // namespace
Expand Down

0 comments on commit aae115c

Please sign in to comment.