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

117 lines
2.6 KiB

  1. #ifndef EAX_EAX_CALL_INCLUDED
  2. #define EAX_EAX_CALL_INCLUDED
  3. #include "AL/al.h"
  4. #include "alspan.h"
  5. #include "eax_api.h"
  6. #include "eax_fx_slot_index.h"
  7. enum class EaxEaxCallPropertySetId
  8. {
  9. none,
  10. context,
  11. fx_slot,
  12. source,
  13. fx_slot_effect,
  14. }; // EaxEaxCallPropertySetId
  15. class EaxEaxCall
  16. {
  17. public:
  18. EaxEaxCall(
  19. bool is_get,
  20. const GUID& property_set_guid,
  21. ALuint property_id,
  22. ALuint property_source_id,
  23. ALvoid* property_buffer,
  24. ALuint property_size);
  25. bool is_get() const noexcept { return is_get_; }
  26. int get_version() const noexcept { return version_; }
  27. EaxEaxCallPropertySetId get_property_set_id() const noexcept { return property_set_id_; }
  28. ALuint get_property_id() const noexcept { return property_id_; }
  29. ALuint get_property_al_name() const noexcept { return property_source_id_; }
  30. EaxFxSlotIndex get_fx_slot_index() const noexcept { return fx_slot_index_; }
  31. template<
  32. typename TException,
  33. typename TValue
  34. >
  35. TValue& get_value() const
  36. {
  37. if (property_size_ < static_cast<ALuint>(sizeof(TValue)))
  38. {
  39. throw TException{"Property buffer too small."};
  40. }
  41. return *static_cast<TValue*>(property_buffer_);
  42. }
  43. template<
  44. typename TException,
  45. typename TValue
  46. >
  47. al::span<TValue> get_values() const
  48. {
  49. if (property_size_ < static_cast<ALuint>(sizeof(TValue)))
  50. {
  51. throw TException{"Property buffer too small."};
  52. }
  53. const auto count = property_size_ / sizeof(TValue);
  54. return al::span<TValue>{static_cast<TValue*>(property_buffer_), count};
  55. }
  56. template<
  57. typename TException,
  58. typename TValue
  59. >
  60. void set_value(
  61. const TValue& value) const
  62. {
  63. get_value<TException, TValue>() = value;
  64. }
  65. private:
  66. const bool is_get_;
  67. int version_;
  68. EaxFxSlotIndex fx_slot_index_;
  69. EaxEaxCallPropertySetId property_set_id_;
  70. ALuint property_id_;
  71. const ALuint property_source_id_;
  72. ALvoid*const property_buffer_;
  73. const ALuint property_size_;
  74. [[noreturn]]
  75. static void fail(
  76. const char* message);
  77. static ALuint convert_eax_v2_0_listener_property_id(
  78. ALuint property_id);
  79. static ALuint convert_eax_v2_0_buffer_property_id(
  80. ALuint property_id);
  81. }; // EaxEaxCall
  82. EaxEaxCall create_eax_call(
  83. bool is_get,
  84. const GUID* property_set_id,
  85. ALuint property_id,
  86. ALuint property_source_id,
  87. ALvoid* property_buffer,
  88. ALuint property_size);
  89. #endif // !EAX_EAX_CALL_INCLUDED