Use virtual functions for the decoder
[openal-soft.git] / al / eax_fx_slots.cpp
blob3a27dabd63bc967f8d2a7177b564d58e4ad11812
1 #include "config.h"
3 #include "eax_fx_slots.h"
5 #include <array>
7 #include "eax_exception.h"
9 #include "eax_api.h"
12 namespace
16 class EaxFxSlotsException :
17 public EaxException
19 public:
20 explicit EaxFxSlotsException(
21 const char* message)
23 EaxException{"EAX_FX_SLOTS", message}
26 }; // EaxFxSlotsException
29 } // namespace
32 void EaxFxSlots::initialize(
33 ALCcontext& al_context)
35 initialize_fx_slots(al_context);
38 void EaxFxSlots::uninitialize() noexcept
40 for (auto& fx_slot : fx_slots_)
42 fx_slot = nullptr;
46 const ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index) const
48 if(!index.has_value())
49 fail("Empty index.");
50 return *fx_slots_[index.value()];
53 ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index)
55 if(!index.has_value())
56 fail("Empty index.");
57 return *fx_slots_[index.value()];
60 void EaxFxSlots::unlock_legacy() noexcept
62 fx_slots_[0]->eax_unlock_legacy();
63 fx_slots_[1]->eax_unlock_legacy();
66 [[noreturn]]
67 void EaxFxSlots::fail(
68 const char* message)
70 throw EaxFxSlotsException{message};
73 void EaxFxSlots::initialize_fx_slots(
74 ALCcontext& al_context)
76 auto fx_slot_index = EaxFxSlotIndexValue{};
78 for (auto& fx_slot : fx_slots_)
80 fx_slot = eax_create_al_effect_slot(al_context);
81 fx_slot->eax_initialize(al_context, fx_slot_index);
82 fx_slot_index += 1;