Don't apply distance attenuation when the slot's AuxSendAuto is off
[openal-soft.git] / al / eax / call.h
blob72f96bbe4934878049976c5f168e90e445fffe42
1 #ifndef EAX_EAX_CALL_INCLUDED
2 #define EAX_EAX_CALL_INCLUDED
4 #include "AL/al.h"
5 #include "alnumeric.h"
6 #include "alspan.h"
7 #include "api.h"
8 #include "fx_slot_index.h"
10 enum class EaxCallType {
11 none,
12 get,
13 set,
14 }; // EaxCallType
16 enum class EaxCallPropertySetId {
17 none,
18 context,
19 fx_slot,
20 source,
21 fx_slot_effect,
22 }; // EaxCallPropertySetId
24 class EaxCall {
25 public:
26 EaxCall(
27 EaxCallType type,
28 const GUID& property_set_guid,
29 ALuint property_id,
30 ALuint property_source_id,
31 ALvoid* property_buffer,
32 ALuint property_size);
34 [[nodiscard]] auto is_get() const noexcept -> bool { return mCallType == EaxCallType::get; }
35 [[nodiscard]] auto is_deferred() const noexcept -> bool { return mIsDeferred; }
36 [[nodiscard]] auto get_version() const noexcept -> int { return mVersion; }
37 [[nodiscard]] auto get_property_set_id() const noexcept -> EaxCallPropertySetId { return mPropertySetId; }
38 [[nodiscard]] auto get_property_id() const noexcept -> ALuint { return mPropertyId; }
39 [[nodiscard]] auto get_property_al_name() const noexcept -> ALuint { return mPropertySourceId; }
40 [[nodiscard]] auto get_fx_slot_index() const noexcept -> EaxFxSlotIndex { return mFxSlotIndex; }
42 template<typename TException, typename TValue>
43 [[nodiscard]] auto get_value() const -> TValue&
45 if(mPropertyBufferSize < sizeof(TValue))
46 fail_too_small();
48 return *static_cast<TValue*>(mPropertyBuffer);
51 template<typename TValue>
52 [[nodiscard]] auto get_values(size_t max_count) const -> al::span<TValue>
54 if(max_count == 0 || mPropertyBufferSize < sizeof(TValue))
55 fail_too_small();
57 const auto count = std::min(mPropertyBufferSize/sizeof(TValue), max_count);
58 return {static_cast<TValue*>(mPropertyBuffer), count};
61 template<typename TValue>
62 [[nodiscard]] auto get_values() const -> al::span<TValue>
64 return get_values<TValue>(~0_uz);
67 template<typename TException, typename TValue>
68 auto set_value(const TValue& value) const -> void
70 get_value<TException, TValue>() = value;
73 private:
74 const EaxCallType mCallType;
75 int mVersion{};
76 EaxFxSlotIndex mFxSlotIndex{};
77 EaxCallPropertySetId mPropertySetId{EaxCallPropertySetId::none};
78 bool mIsDeferred;
80 const ALuint mPropertyId;
81 const ALuint mPropertySourceId;
82 ALvoid*const mPropertyBuffer;
83 const ALuint mPropertyBufferSize;
85 [[noreturn]] static void fail(const char* message);
86 [[noreturn]] static void fail_too_small();
87 }; // EaxCall
89 EaxCall create_eax_call(
90 EaxCallType type,
91 const GUID* property_set_id,
92 ALuint property_id,
93 ALuint property_source_id,
94 ALvoid* property_buffer,
95 ALuint property_size);
97 #endif // !EAX_EAX_CALL_INCLUDED