2021-04-28 12:43:51 +08:00
|
|
|
#ifndef AL_AUXEFFECTSLOT_H
|
|
|
|
#define AL_AUXEFFECTSLOT_H
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
#include "AL/al.h"
|
|
|
|
#include "AL/alc.h"
|
|
|
|
#include "AL/efx.h"
|
|
|
|
|
2021-05-14 10:15:42 +08:00
|
|
|
#include "alc/device.h"
|
|
|
|
#include "alc/effects/base.h"
|
2021-04-28 12:43:51 +08:00
|
|
|
#include "almalloc.h"
|
|
|
|
#include "atomic.h"
|
2022-04-25 12:02:45 +08:00
|
|
|
#include "core/effectslot.h"
|
2021-04-28 12:43:51 +08:00
|
|
|
#include "intrusive_ptr.h"
|
|
|
|
#include "vector.h"
|
|
|
|
|
2022-04-25 12:02:45 +08:00
|
|
|
#ifdef ALSOFT_EAX
|
|
|
|
#include <memory>
|
2022-07-14 23:17:11 +08:00
|
|
|
#include "eax/call.h"
|
|
|
|
#include "eax/effect.h"
|
|
|
|
#include "eax/fx_slot_index.h"
|
2022-04-25 12:02:45 +08:00
|
|
|
#endif // ALSOFT_EAX
|
|
|
|
|
2021-04-28 12:43:51 +08:00
|
|
|
struct ALbuffer;
|
|
|
|
struct ALeffect;
|
|
|
|
struct WetBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
enum class SlotState : ALenum {
|
|
|
|
Initial = AL_INITIAL,
|
|
|
|
Playing = AL_PLAYING,
|
|
|
|
Stopped = AL_STOPPED,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ALeffectslot {
|
|
|
|
float Gain{1.0f};
|
|
|
|
bool AuxSendAuto{true};
|
|
|
|
ALeffectslot *Target{nullptr};
|
|
|
|
ALbuffer *Buffer{nullptr};
|
|
|
|
|
|
|
|
struct {
|
|
|
|
EffectSlotType Type{EffectSlotType::None};
|
|
|
|
EffectProps Props{};
|
|
|
|
|
|
|
|
al::intrusive_ptr<EffectState> State;
|
|
|
|
} Effect;
|
|
|
|
|
2022-04-25 12:02:45 +08:00
|
|
|
bool mPropsDirty{true};
|
2021-04-28 12:43:51 +08:00
|
|
|
|
|
|
|
SlotState mState{SlotState::Initial};
|
|
|
|
|
|
|
|
RefCount ref{0u};
|
|
|
|
|
|
|
|
EffectSlot mSlot;
|
|
|
|
|
|
|
|
/* Self ID */
|
|
|
|
ALuint id{};
|
|
|
|
|
|
|
|
ALeffectslot();
|
|
|
|
ALeffectslot(const ALeffectslot&) = delete;
|
|
|
|
ALeffectslot& operator=(const ALeffectslot&) = delete;
|
|
|
|
~ALeffectslot();
|
|
|
|
|
2022-04-25 12:02:45 +08:00
|
|
|
ALenum initEffect(ALenum effectType, const EffectProps &effectProps, ALCcontext *context);
|
2021-04-28 12:43:51 +08:00
|
|
|
void updateProps(ALCcontext *context);
|
|
|
|
|
|
|
|
/* This can be new'd for the context's default effect slot. */
|
|
|
|
DEF_NEWDEL(ALeffectslot)
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef ALSOFT_EAX
|
|
|
|
public:
|
|
|
|
void eax_initialize(
|
2022-07-14 23:17:11 +08:00
|
|
|
const EaxCall& call,
|
2022-04-25 12:02:45 +08:00
|
|
|
ALCcontext& al_context,
|
|
|
|
EaxFxSlotIndexValue index);
|
|
|
|
|
|
|
|
const EAX50FXSLOTPROPERTIES& eax_get_eax_fx_slot() const noexcept;
|
|
|
|
|
|
|
|
|
|
|
|
// [[nodiscard]]
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_dispatch(const EaxCall& call)
|
|
|
|
{ return call.is_get() ? eax_get(call) : eax_set(call); }
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
void eax_unlock_legacy() noexcept;
|
|
|
|
|
|
|
|
void eax_commit() { eax_apply_deferred(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
ALCcontext* eax_al_context_{};
|
|
|
|
|
|
|
|
EaxFxSlotIndexValue eax_fx_slot_index_{};
|
|
|
|
|
|
|
|
EAX50FXSLOTPROPERTIES eax_eax_fx_slot_{};
|
|
|
|
|
|
|
|
EaxEffectUPtr eax_effect_{};
|
|
|
|
bool eax_is_locked_{};
|
|
|
|
|
|
|
|
|
|
|
|
[[noreturn]]
|
|
|
|
static void eax_fail(
|
|
|
|
const char* message);
|
|
|
|
|
|
|
|
|
|
|
|
GUID eax_get_eax_default_effect_guid() const noexcept;
|
|
|
|
long eax_get_eax_default_lock() const noexcept;
|
|
|
|
|
|
|
|
void eax_set_eax_fx_slot_defaults();
|
|
|
|
|
|
|
|
void eax_initialize_eax();
|
|
|
|
|
|
|
|
void eax_initialize_lock();
|
|
|
|
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_initialize_effects(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_get_fx_slot_all(const EaxCall& call) const;
|
2022-04-25 12:02:45 +08:00
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_get_fx_slot(const EaxCall& call) const;
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
// [[nodiscard]]
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_get(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_set_fx_slot_effect(const EaxCall& call, ALenum effect_type);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_set_fx_slot_effect(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
void eax_set_efx_effect_slot_gain();
|
|
|
|
|
|
|
|
void eax_set_fx_slot_volume();
|
|
|
|
|
|
|
|
|
|
|
|
void eax_set_effect_slot_send_auto();
|
|
|
|
|
|
|
|
void eax_set_fx_slot_flags();
|
|
|
|
|
|
|
|
|
|
|
|
void eax_ensure_is_unlocked() const;
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_validate_fx_slot_effect(const GUID& eax_effect_id);
|
|
|
|
void eax_validate_fx_slot_volume(long eax_volume);
|
|
|
|
void eax_validate_fx_slot_lock(long eax_lock);
|
|
|
|
void eax_validate_fx_slot_flags(const EaxCall& call, unsigned long eax_flags);
|
|
|
|
void eax_validate_fx_slot_occlusion(long eax_occlusion);
|
|
|
|
void eax_validate_fx_slot_occlusion_lf_ratio(float eax_occlusion_lf_ratio);
|
|
|
|
void eax_validate_fx_slot_all(const EaxCall& call, const EAX40FXSLOTPROPERTIES& fx_slot);
|
|
|
|
void eax_validate_fx_slot_all(const EaxCall& call, const EAX50FXSLOTPROPERTIES& fx_slot);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_set_fx_slot_effect(const EaxCall& call, const GUID& eax_effect_id);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
void eax_set_fx_slot_volume(
|
|
|
|
long eax_volume);
|
|
|
|
|
|
|
|
void eax_set_fx_slot_lock(
|
|
|
|
long eax_lock);
|
|
|
|
|
|
|
|
void eax_set_fx_slot_flags(
|
|
|
|
unsigned long eax_flags);
|
|
|
|
|
|
|
|
// [[nodiscard]]
|
|
|
|
bool eax_set_fx_slot_occlusion(
|
|
|
|
long eax_occlusion);
|
|
|
|
|
|
|
|
// [[nodiscard]]
|
|
|
|
bool eax_set_fx_slot_occlusion_lf_ratio(
|
|
|
|
float eax_occlusion_lf_ratio);
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_set_fx_slot_all(const EaxCall& call, const EAX40FXSLOTPROPERTIES& eax_fx_slot);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
// [[nodiscard]]
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_set_fx_slot_all(const EaxCall& call, const EAX50FXSLOTPROPERTIES& eax_fx_slot);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_defer_fx_slot_effect(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_defer_fx_slot_volume(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_defer_fx_slot_lock(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_defer_fx_slot_flags(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
// [[nodiscard]]
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_defer_fx_slot_occlusion(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
// [[nodiscard]]
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_defer_fx_slot_occlusion_lf_ratio(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
// [[nodiscard]]
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_defer_fx_slot_all(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_set_fx_slot(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
void eax_apply_deferred();
|
|
|
|
|
|
|
|
// [[nodiscard]]
|
2022-07-14 23:17:11 +08:00
|
|
|
bool eax_set(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
2022-07-14 23:17:11 +08:00
|
|
|
void eax_dispatch_effect(const EaxCall& call);
|
2022-04-25 12:02:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
// `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_EFFECT, effect)`
|
|
|
|
void eax_set_effect_slot_effect(EaxEffect &effect);
|
|
|
|
|
|
|
|
// `alAuxiliaryEffectSloti(effect_slot, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, value)`
|
|
|
|
void eax_set_effect_slot_send_auto(bool is_send_auto);
|
|
|
|
|
|
|
|
// `alAuxiliaryEffectSlotf(effect_slot, AL_EFFECTSLOT_GAIN, gain)`
|
|
|
|
void eax_set_effect_slot_gain(ALfloat gain);
|
|
|
|
|
|
|
|
public:
|
|
|
|
class EaxDeleter {
|
|
|
|
public:
|
|
|
|
void operator()(ALeffectslot *effect_slot);
|
|
|
|
}; // EaxAlEffectSlotDeleter
|
|
|
|
#endif // ALSOFT_EAX
|
2021-04-28 12:43:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void UpdateAllEffectSlotProps(ALCcontext *context);
|
|
|
|
|
2022-04-25 12:02:45 +08:00
|
|
|
#ifdef ALSOFT_EAX
|
|
|
|
|
|
|
|
using EaxAlEffectSlotUPtr = std::unique_ptr<ALeffectslot, ALeffectslot::EaxDeleter>;
|
|
|
|
|
|
|
|
|
|
|
|
EaxAlEffectSlotUPtr eax_create_al_effect_slot(
|
|
|
|
ALCcontext& context);
|
|
|
|
|
|
|
|
void eax_delete_al_effect_slot(
|
|
|
|
ALCcontext& context,
|
|
|
|
ALeffectslot& effect_slot);
|
|
|
|
#endif // ALSOFT_EAX
|
|
|
|
|
2021-04-28 12:43:51 +08:00
|
|
|
#endif
|