Move EAX files to their own sub-directory
[openal-soft.git] / al / eax / fx_slots.cpp
blob5897e95109034b12704b78484676f9e0dedd9dfc
1 #include "config.h"
3 #include "fx_slots.h"
5 #include <array>
7 #include "api.h"
8 #include "exception.h"
11 namespace
15 class EaxFxSlotsException :
16 public EaxException
18 public:
19 explicit EaxFxSlotsException(
20 const char* message)
22 EaxException{"EAX_FX_SLOTS", message}
25 }; // EaxFxSlotsException
28 } // namespace
31 void EaxFxSlots::initialize(
32 ALCcontext& al_context)
34 initialize_fx_slots(al_context);
37 void EaxFxSlots::uninitialize() noexcept
39 for (auto& fx_slot : fx_slots_)
41 fx_slot = nullptr;
45 const ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index) const
47 if(!index.has_value())
48 fail("Empty index.");
49 return *fx_slots_[index.value()];
52 ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index)
54 if(!index.has_value())
55 fail("Empty index.");
56 return *fx_slots_[index.value()];
59 void EaxFxSlots::unlock_legacy() noexcept
61 fx_slots_[0]->eax_unlock_legacy();
62 fx_slots_[1]->eax_unlock_legacy();
65 [[noreturn]]
66 void EaxFxSlots::fail(
67 const char* message)
69 throw EaxFxSlotsException{message};
72 void EaxFxSlots::initialize_fx_slots(
73 ALCcontext& al_context)
75 auto fx_slot_index = EaxFxSlotIndexValue{};
77 for (auto& fx_slot : fx_slots_)
79 fx_slot = eax_create_al_effect_slot(al_context);
80 fx_slot->eax_initialize(al_context, fx_slot_index);
81 fx_slot_index += 1;