Improve handling the async wake interval
[alure.git] / src / auxeffectslot.cpp
blob000754092015c786537e0e0a943c7afe6e824fba
2 #include "config.h"
4 #include "auxeffectslot.h"
6 #include <stdexcept>
8 #include "al.h"
9 #include "alext.h"
11 #include "context.h"
12 #include "effect.h"
14 namespace alure
17 void ALAuxiliaryEffectSlot::setGain(ALfloat gain)
19 if(!(gain >= 0.0f && gain <= 1.0f))
20 throw std::runtime_error("Gain out of range");
21 CheckContext(mContext);
22 mContext->alAuxiliaryEffectSlotf(mId, AL_EFFECTSLOT_GAIN, gain);
25 void ALAuxiliaryEffectSlot::setSendAuto(bool sendauto)
27 CheckContext(mContext);
28 mContext->alAuxiliaryEffectSloti(mId, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, sendauto ? AL_TRUE : AL_FALSE);
31 void ALAuxiliaryEffectSlot::applyEffect(Effect effect)
33 const ALEffect *eff = effect.getHandle();
34 if(!eff) throw std::runtime_error("Invalid Effect");
35 CheckContext(mContext);
37 mContext->alAuxiliaryEffectSloti(mId, AL_EFFECTSLOT_EFFECT, eff->getId());
41 void ALAuxiliaryEffectSlot::release()
43 CheckContext(mContext);
44 if(isInUse())
45 throw std::runtime_error("AuxiliaryEffectSlot is in use");
47 alGetError();
48 mContext->alDeleteAuxiliaryEffectSlots(1, &mId);
49 if(alGetError() != AL_NO_ERROR)
50 throw std::runtime_error("AuxiliaryEffectSlot failed to delete");
51 mId = 0;
53 delete this;
57 DECL_THUNK1(void, AuxiliaryEffectSlot, setGain,, ALfloat)
58 DECL_THUNK1(void, AuxiliaryEffectSlot, setSendAuto,, bool)
59 DECL_THUNK1(void, AuxiliaryEffectSlot, applyEffect,, Effect)
60 void AuxiliaryEffectSlot::release()
62 pImpl->release();
63 pImpl = nullptr;
65 DECL_THUNK0(Vector<SourceSend>, AuxiliaryEffectSlot, getSourceSends, const)
66 DECL_THUNK0(bool, AuxiliaryEffectSlot, isInUse, const)
68 } // namespace alure