🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.4 KiB

  1. #include "config.h"
  2. #include "eax_fx_slots.h"
  3. #include <array>
  4. #include "eax_exception.h"
  5. #include "eax_api.h"
  6. namespace
  7. {
  8. class EaxFxSlotsException :
  9. public EaxException
  10. {
  11. public:
  12. explicit EaxFxSlotsException(
  13. const char* message)
  14. :
  15. EaxException{"EAX_FX_SLOTS", message}
  16. {
  17. }
  18. }; // EaxFxSlotsException
  19. } // namespace
  20. void EaxFxSlots::initialize(
  21. ALCcontext& al_context)
  22. {
  23. initialize_fx_slots(al_context);
  24. }
  25. void EaxFxSlots::uninitialize() noexcept
  26. {
  27. for (auto& fx_slot : fx_slots_)
  28. {
  29. fx_slot = nullptr;
  30. }
  31. }
  32. const ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index) const
  33. {
  34. if(!index.has_value())
  35. fail("Empty index.");
  36. return *fx_slots_[index.value()];
  37. }
  38. ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index)
  39. {
  40. if(!index.has_value())
  41. fail("Empty index.");
  42. return *fx_slots_[index.value()];
  43. }
  44. void EaxFxSlots::unlock_legacy() noexcept
  45. {
  46. fx_slots_[0]->eax_unlock_legacy();
  47. fx_slots_[1]->eax_unlock_legacy();
  48. }
  49. [[noreturn]]
  50. void EaxFxSlots::fail(
  51. const char* message)
  52. {
  53. throw EaxFxSlotsException{message};
  54. }
  55. void EaxFxSlots::initialize_fx_slots(
  56. ALCcontext& al_context)
  57. {
  58. auto fx_slot_index = EaxFxSlotIndexValue{};
  59. for (auto& fx_slot : fx_slots_)
  60. {
  61. fx_slot = eax_create_al_effect_slot(al_context);
  62. fx_slot->eax_initialize(al_context, fx_slot_index);
  63. fx_slot_index += 1;
  64. }
  65. }