diff options
Diffstat (limited to 'al')
-rw-r--r-- | al/eax/call.cpp | 139 | ||||
-rw-r--r-- | al/eax/call.h | 46 |
2 files changed, 84 insertions, 101 deletions
diff --git a/al/eax/call.cpp b/al/eax/call.cpp index f00ab5be..689d5cf1 100644 --- a/al/eax/call.cpp +++ b/al/eax/call.cpp @@ -22,12 +22,12 @@ EaxCall::EaxCall( ALuint property_source_id, ALvoid* property_buffer, ALuint property_size) - : type_{type}, version_{0}, property_set_id_{EaxCallPropertySetId::none} - , is_deferred_{(property_id & deferred_flag) != 0} - , property_id_{property_id & ~deferred_flag}, property_source_id_{property_source_id} - , property_buffer_{property_buffer}, property_size_{property_size} + : mCallType{type}, mVersion{0}, mPropertySetId{EaxCallPropertySetId::none} + , mIsDeferred{(property_id & deferred_flag) != 0} + , mPropertyId{property_id & ~deferred_flag}, mPropertySourceId{property_source_id} + , mPropertyBuffer{property_buffer}, mPropertyBufferSize{property_size} { - switch (type_) + switch(mCallType) { case EaxCallType::get: case EaxCallType::set: @@ -42,116 +42,111 @@ EaxCall::EaxCall( } else if (property_set_guid == EAXPROPERTYID_EAX40_Context) { - version_ = 4; - property_set_id_ = EaxCallPropertySetId::context; + mVersion = 4; + mPropertySetId = EaxCallPropertySetId::context; } else if (property_set_guid == EAXPROPERTYID_EAX50_Context) { - version_ = 5; - property_set_id_ = EaxCallPropertySetId::context; + mVersion = 5; + mPropertySetId = EaxCallPropertySetId::context; } else if (property_set_guid == DSPROPSETID_EAX20_ListenerProperties) { - version_ = 2; - fx_slot_index_ = 0u; - property_set_id_ = EaxCallPropertySetId::fx_slot_effect; + mVersion = 2; + mFxSlotIndex = 0u; + mPropertySetId = EaxCallPropertySetId::fx_slot_effect; } else if (property_set_guid == DSPROPSETID_EAX30_ListenerProperties) { - version_ = 3; - fx_slot_index_ = 0u; - property_set_id_ = EaxCallPropertySetId::fx_slot_effect; + mVersion = 3; + mFxSlotIndex = 0u; + mPropertySetId = EaxCallPropertySetId::fx_slot_effect; } else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot0) { - version_ = 4; - fx_slot_index_ = 0u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 4; + mFxSlotIndex = 0u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot0) { - version_ = 5; - fx_slot_index_ = 0u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 5; + mFxSlotIndex = 0u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot1) { - version_ = 4; - fx_slot_index_ = 1u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 4; + mFxSlotIndex = 1u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot1) { - version_ = 5; - fx_slot_index_ = 1u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 5; + mFxSlotIndex = 1u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot2) { - version_ = 4; - fx_slot_index_ = 2u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 4; + mFxSlotIndex = 2u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot2) { - version_ = 5; - fx_slot_index_ = 2u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 5; + mFxSlotIndex = 2u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == EAXPROPERTYID_EAX40_FXSlot3) { - version_ = 4; - fx_slot_index_ = 3u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 4; + mFxSlotIndex = 3u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == EAXPROPERTYID_EAX50_FXSlot3) { - version_ = 5; - fx_slot_index_ = 3u; - property_set_id_ = EaxCallPropertySetId::fx_slot; + mVersion = 5; + mFxSlotIndex = 3u; + mPropertySetId = EaxCallPropertySetId::fx_slot; } else if (property_set_guid == DSPROPSETID_EAX20_BufferProperties) { - version_ = 2; - property_set_id_ = EaxCallPropertySetId::source; + mVersion = 2; + mPropertySetId = EaxCallPropertySetId::source; } else if (property_set_guid == DSPROPSETID_EAX30_BufferProperties) { - version_ = 3; - property_set_id_ = EaxCallPropertySetId::source; + mVersion = 3; + mPropertySetId = EaxCallPropertySetId::source; } else if (property_set_guid == EAXPROPERTYID_EAX40_Source) { - version_ = 4; - property_set_id_ = EaxCallPropertySetId::source; + mVersion = 4; + mPropertySetId = EaxCallPropertySetId::source; } else if (property_set_guid == EAXPROPERTYID_EAX50_Source) { - version_ = 5; - property_set_id_ = EaxCallPropertySetId::source; + mVersion = 5; + mPropertySetId = EaxCallPropertySetId::source; } else if (property_set_guid == DSPROPSETID_EAX_ReverbProperties) { - version_ = 1; - fx_slot_index_ = 0u; - property_set_id_ = EaxCallPropertySetId::fx_slot_effect; + mVersion = 1; + mFxSlotIndex = 0u; + mPropertySetId = EaxCallPropertySetId::fx_slot_effect; } else if (property_set_guid == DSPROPSETID_EAXBUFFER_ReverbProperties) { - version_ = 1; - property_set_id_ = EaxCallPropertySetId::source; + mVersion = 1; + mPropertySetId = EaxCallPropertySetId::source; } else { fail("Unsupported property set id."); } - if (version_ < 1 || version_ > 5) - { - fail("EAX version out of range."); - } - - switch(property_id_) + switch(mPropertyId) { case EAXCONTEXT_LASTERROR: case EAXCONTEXT_SPEAKERCONFIG: @@ -166,39 +161,29 @@ EaxCall::EaxCall( case EAXFXSLOT_OCCLUSIONLFRATIO: // EAX allow to set "defer" flag on immediate-only properties. // If we don't clear our flag then "applyAllUpdates" in EAX context won't be called. - is_deferred_ = false; - break; - default: + mIsDeferred = false; break; } - if(!is_deferred_) + if(!mIsDeferred) { - if(property_set_id_ != EaxCallPropertySetId::fx_slot && property_id_ != 0) + if(mPropertySetId != EaxCallPropertySetId::fx_slot && mPropertyId != 0) { - if (property_buffer == nullptr) - { + if(mPropertyBuffer == nullptr) fail("Null property buffer."); - } - if (property_size == 0) - { + if(mPropertyBufferSize == 0) fail("Empty property."); - } } } - if(property_set_id_ == EaxCallPropertySetId::source && property_source_id_ == 0) - { + if(mPropertySetId == EaxCallPropertySetId::source && mPropertySourceId == 0) fail("Null AL source id."); - } - if (property_set_id_ == EaxCallPropertySetId::fx_slot) + if(mPropertySetId == EaxCallPropertySetId::fx_slot) { - if (property_id_ < EAXFXSLOT_NONE) - { - property_set_id_ = EaxCallPropertySetId::fx_slot_effect; - } + if(mPropertyId < EAXFXSLOT_NONE) + mPropertySetId = EaxCallPropertySetId::fx_slot_effect; } } diff --git a/al/eax/call.h b/al/eax/call.h index 4c35551c..5ec33b0f 100644 --- a/al/eax/call.h +++ b/al/eax/call.h @@ -31,33 +31,31 @@ public: ALvoid* property_buffer, ALuint property_size); - bool is_get() const noexcept { return type_ == EaxCallType::get; } - bool is_deferred() const noexcept { return is_deferred_; } - int get_version() const noexcept { return version_; } - EaxCallPropertySetId get_property_set_id() const noexcept { return property_set_id_; } - ALuint get_property_id() const noexcept { return property_id_; } - ALuint get_property_al_name() const noexcept { return property_source_id_; } - EaxFxSlotIndex get_fx_slot_index() const noexcept { return fx_slot_index_; } + bool is_get() const noexcept { return mCallType == EaxCallType::get; } + bool is_deferred() const noexcept { return mIsDeferred; } + int get_version() const noexcept { return mVersion; } + EaxCallPropertySetId get_property_set_id() const noexcept { return mPropertySetId; } + ALuint get_property_id() const noexcept { return mPropertyId; } + ALuint get_property_al_name() const noexcept { return mPropertySourceId; } + EaxFxSlotIndex get_fx_slot_index() const noexcept { return mFxSlotIndex; } template<typename TException, typename TValue> TValue& get_value() const { - if (property_size_ < static_cast<ALuint>(sizeof(TValue))) - { + if(mPropertyBufferSize < sizeof(TValue)) fail_too_small(); - } - return *static_cast<TValue*>(property_buffer_); + return *static_cast<TValue*>(mPropertyBuffer); } template<typename TValue> al::span<TValue> get_values(size_t max_count) const { - if (max_count == 0 || property_size_ < static_cast<ALuint>(sizeof(TValue))) + if(max_count == 0 || mPropertyBufferSize < sizeof(TValue)) fail_too_small(); - const auto count = minz(property_size_ / sizeof(TValue), max_count); - return al::span<TValue>{static_cast<TValue*>(property_buffer_), count}; + const auto count = minz(mPropertyBufferSize / sizeof(TValue), max_count); + return al::as_span(static_cast<TValue*>(mPropertyBuffer), count); } template<typename TValue> @@ -73,16 +71,16 @@ public: } private: - EaxCallType type_; - int version_; - EaxFxSlotIndex fx_slot_index_; - EaxCallPropertySetId property_set_id_; - bool is_deferred_; - - ALuint property_id_; - ALuint property_source_id_; - ALvoid*property_buffer_; - ALuint property_size_; + const EaxCallType mCallType; + int mVersion; + EaxFxSlotIndex mFxSlotIndex; + EaxCallPropertySetId mPropertySetId; + bool mIsDeferred; + + const ALuint mPropertyId; + const ALuint mPropertySourceId; + ALvoid*const mPropertyBuffer; + const ALuint mPropertyBufferSize; [[noreturn]] static void fail(const char* message); [[noreturn]] static void fail_too_small(); |