diff options
author | Chris Robinson <[email protected]> | 2022-05-16 02:08:18 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-05-16 02:08:18 -0700 |
commit | 65e4c20c27f2acf853e58fd4c26ebc0e3eb926c6 (patch) | |
tree | 4fb9a3bffbda4ab8dc1363caa2426cf8e8bbf30e /al/eax/fx_slots.cpp | |
parent | 83238973ed08225adf03e76b6933e0c209f93fd9 (diff) |
Move EAX files to their own sub-directory
Diffstat (limited to 'al/eax/fx_slots.cpp')
-rw-r--r-- | al/eax/fx_slots.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/al/eax/fx_slots.cpp b/al/eax/fx_slots.cpp new file mode 100644 index 00000000..5897e951 --- /dev/null +++ b/al/eax/fx_slots.cpp @@ -0,0 +1,83 @@ +#include "config.h" + +#include "fx_slots.h" + +#include <array> + +#include "api.h" +#include "exception.h" + + +namespace +{ + + +class EaxFxSlotsException : + public EaxException +{ +public: + explicit EaxFxSlotsException( + const char* message) + : + EaxException{"EAX_FX_SLOTS", message} + { + } +}; // EaxFxSlotsException + + +} // namespace + + +void EaxFxSlots::initialize( + ALCcontext& al_context) +{ + initialize_fx_slots(al_context); +} + +void EaxFxSlots::uninitialize() noexcept +{ + for (auto& fx_slot : fx_slots_) + { + fx_slot = nullptr; + } +} + +const ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index) const +{ + if(!index.has_value()) + fail("Empty index."); + return *fx_slots_[index.value()]; +} + +ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index) +{ + if(!index.has_value()) + fail("Empty index."); + return *fx_slots_[index.value()]; +} + +void EaxFxSlots::unlock_legacy() noexcept +{ + fx_slots_[0]->eax_unlock_legacy(); + fx_slots_[1]->eax_unlock_legacy(); +} + +[[noreturn]] +void EaxFxSlots::fail( + const char* message) +{ + throw EaxFxSlotsException{message}; +} + +void EaxFxSlots::initialize_fx_slots( + ALCcontext& al_context) +{ + auto fx_slot_index = EaxFxSlotIndexValue{}; + + for (auto& fx_slot : fx_slots_) + { + fx_slot = eax_create_al_effect_slot(al_context); + fx_slot->eax_initialize(al_context, fx_slot_index); + fx_slot_index += 1; + } +} |