A non-async stream is dead, don't try refilling it
[alure.git] / src / auxeffectslot.h
blobc275da5e9ca046858862789ac648c284f4326475
1 #ifndef AUXEFFECTSLOT_H
2 #define AUXEFFECTSLOT_H
4 #include <algorithm>
6 #include "main.h"
8 #include "al.h"
10 #include "refcount.h"
12 namespace alure {
14 class ALContext;
16 inline bool operator==(const SourceSend &lhs, const SourceSend &rhs)
17 { return lhs.mSource == rhs.mSource && lhs.mSend == rhs.mSend; }
19 class ALAuxiliaryEffectSlot : public AuxiliaryEffectSlot {
20 ALContext *const mContext;
21 ALuint mId;
23 std::vector<SourceSend> mSourceSends;
25 public:
26 ALAuxiliaryEffectSlot(ALContext *context, ALuint id)
27 : mContext(context), mId(id)
28 { }
29 virtual ~ALAuxiliaryEffectSlot() { }
31 void addSourceSend(Source *source, ALuint send) { mSourceSends.push_back({source, send}); }
32 void removeSourceSend(Source *source, ALuint send)
34 auto iter = std::find(mSourceSends.cbegin(), mSourceSends.cend(), SourceSend{source, send});
35 if(iter != mSourceSends.cend()) mSourceSends.erase(iter);
38 ALContext *getContext() { return mContext; }
39 const ALuint &getId() const { return mId; }
41 virtual void setGain(ALfloat gain) final;
42 virtual void setSendAuto(bool sendauto) final;
44 virtual void applyEffect(const Effect *effect) final;
46 virtual void release() final;
48 virtual std::vector<SourceSend> getSourceSends() const final { return mSourceSends; }
50 virtual bool isInUse() const final { return (mSourceSends.size() > 0); }
53 } // namespace alure
55 #endif /* AUXEFFECTSLOT_H */