4 #include "auxeffectslot.h"
17 static inline bool operator<(const SourceSend
&lhs
, const SourceSend
&rhs
)
18 { return lhs
.mSource
< rhs
.mSource
|| (lhs
.mSource
== rhs
.mSource
&& lhs
.mSend
< rhs
.mSend
); }
19 static inline bool operator==(const SourceSend
&lhs
, const SourceSend
&rhs
)
20 { return lhs
.mSource
== rhs
.mSource
&& lhs
.mSend
== rhs
.mSend
; }
21 static inline bool operator!=(const SourceSend
&lhs
, const SourceSend
&rhs
)
22 { return !(lhs
== rhs
); }
24 void AuxiliaryEffectSlotImpl::addSourceSend(SourceSend source_send
)
26 auto iter
= std::lower_bound(mSourceSends
.begin(), mSourceSends
.end(), source_send
);
27 if(iter
== mSourceSends
.end() || *iter
!= source_send
)
28 mSourceSends
.insert(iter
, source_send
);
31 void AuxiliaryEffectSlotImpl::removeSourceSend(SourceSend source_send
)
33 auto iter
= std::lower_bound(mSourceSends
.begin(), mSourceSends
.end(), source_send
);
34 if(iter
!= mSourceSends
.end() && *iter
== source_send
)
35 mSourceSends
.erase(iter
);
39 void AuxiliaryEffectSlotImpl::setGain(ALfloat gain
)
41 if(!(gain
>= 0.0f
&& gain
<= 1.0f
))
42 throw std::runtime_error("Gain out of range");
43 CheckContext(mContext
);
44 mContext
->alAuxiliaryEffectSlotf(mId
, AL_EFFECTSLOT_GAIN
, gain
);
47 void AuxiliaryEffectSlotImpl::setSendAuto(bool sendauto
)
49 CheckContext(mContext
);
50 mContext
->alAuxiliaryEffectSloti(mId
, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO
, sendauto
? AL_TRUE
: AL_FALSE
);
53 void AuxiliaryEffectSlotImpl::applyEffect(Effect effect
)
55 const EffectImpl
*eff
= effect
.getHandle();
56 if(!eff
) throw std::runtime_error("Invalid Effect");
57 CheckContext(mContext
);
59 mContext
->alAuxiliaryEffectSloti(mId
, AL_EFFECTSLOT_EFFECT
, eff
->getId());
63 void AuxiliaryEffectSlotImpl::release()
65 CheckContext(mContext
);
67 throw std::runtime_error("AuxiliaryEffectSlot is in use");
70 mContext
->alDeleteAuxiliaryEffectSlots(1, &mId
);
71 if(alGetError() != AL_NO_ERROR
)
72 throw std::runtime_error("AuxiliaryEffectSlot failed to delete");
79 DECL_THUNK1(void, AuxiliaryEffectSlot
, setGain
,, ALfloat
)
80 DECL_THUNK1(void, AuxiliaryEffectSlot
, setSendAuto
,, bool)
81 DECL_THUNK1(void, AuxiliaryEffectSlot
, applyEffect
,, Effect
)
82 void AuxiliaryEffectSlot::release()
87 DECL_THUNK0(Vector
<SourceSend
>, AuxiliaryEffectSlot
, getSourceSends
, const)
88 DECL_THUNK0(bool, AuxiliaryEffectSlot
, isInUse
, const)