🛠️🐜 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.

85 lines
1.5 KiB

  1. #include "config.h"
  2. #include "fx_slots.h"
  3. #include <array>
  4. #include "api.h"
  5. #include "exception.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. const EaxCall& call,
  22. ALCcontext& al_context)
  23. {
  24. initialize_fx_slots(call, al_context);
  25. }
  26. void EaxFxSlots::uninitialize() noexcept
  27. {
  28. for (auto& fx_slot : fx_slots_)
  29. {
  30. fx_slot = nullptr;
  31. }
  32. }
  33. const ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index) const
  34. {
  35. if(!index.has_value())
  36. fail("Empty index.");
  37. return *fx_slots_[index.value()];
  38. }
  39. ALeffectslot& EaxFxSlots::get(EaxFxSlotIndex index)
  40. {
  41. if(!index.has_value())
  42. fail("Empty index.");
  43. return *fx_slots_[index.value()];
  44. }
  45. void EaxFxSlots::unlock_legacy() noexcept
  46. {
  47. fx_slots_[0]->eax_unlock_legacy();
  48. fx_slots_[1]->eax_unlock_legacy();
  49. }
  50. [[noreturn]]
  51. void EaxFxSlots::fail(
  52. const char* message)
  53. {
  54. throw EaxFxSlotsException{message};
  55. }
  56. void EaxFxSlots::initialize_fx_slots(
  57. const EaxCall& call,
  58. ALCcontext& al_context)
  59. {
  60. auto fx_slot_index = EaxFxSlotIndexValue{};
  61. for (auto& fx_slot : fx_slots_)
  62. {
  63. fx_slot = eax_create_al_effect_slot(al_context);
  64. fx_slot->eax_initialize(call, al_context, fx_slot_index);
  65. fx_slot_index += 1;
  66. }
  67. }