[EAX] Add separate source state for each version (#720)

This commit is contained in:
Boris I. Bendovsky 2022-06-18 23:36:42 +03:00 committed by GitHub
parent 0e7d5736c0
commit d21ff67554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1828 additions and 2757 deletions

View File

@ -313,7 +313,7 @@ bool operator==(
lhs.flOcclusionLFRatio == rhs.flOcclusionLFRatio;
}
const EAX50ACTIVEFXSLOTS EAX40SOURCE_DEFAULTACTIVEFXSLOTID = EAX50ACTIVEFXSLOTS
const EAX40ACTIVEFXSLOTS EAX40SOURCE_DEFAULTACTIVEFXSLOTID = EAX40ACTIVEFXSLOTS
{{
EAX_NULL_GUID,
EAXPROPERTYID_EAX40_FXSlot0,

View File

@ -275,6 +275,10 @@ struct EAX20BUFFERPROPERTIES
unsigned long dwFlags; // modifies the behavior of properties
}; // EAX20BUFFERPROPERTIES
inline bool operator==(const EAX20BUFFERPROPERTIES& lhs, const EAX20BUFFERPROPERTIES& rhs) noexcept
{
return std::memcmp(&lhs, &rhs, sizeof(EAX20BUFFERPROPERTIES)) == 0;
}
extern const GUID DSPROPSETID_EAX30_ListenerProperties;
@ -707,12 +711,21 @@ struct EAX30SOURCEPROPERTIES
unsigned long ulFlags; // modifies the behavior of properties
}; // EAX30SOURCEPROPERTIES
struct EAX50SOURCEPROPERTIES :
public EAX30SOURCEPROPERTIES
inline bool operator==(const EAX30SOURCEPROPERTIES& lhs, const EAX30SOURCEPROPERTIES& rhs) noexcept
{
return std::memcmp(&lhs, &rhs, sizeof(EAX30SOURCEPROPERTIES)) == 0;
}
struct EAX50SOURCEPROPERTIES : public EAX30SOURCEPROPERTIES
{
float flMacroFXFactor;
}; // EAX50SOURCEPROPERTIES
inline bool operator==(const EAX50SOURCEPROPERTIES& lhs, const EAX50SOURCEPROPERTIES& rhs) noexcept
{
return std::memcmp(&lhs, &rhs, sizeof(EAX50SOURCEPROPERTIES)) == 0;
}
struct EAXSOURCEALLSENDPROPERTIES
{
GUID guidReceivingFXSlotID;
@ -808,7 +821,7 @@ struct EAXSOURCEEXCLUSIONSENDPROPERTIES
float flExclusionLFRatio;
}; // EAXSOURCEEXCLUSIONSENDPROPERTIES
extern const EAX50ACTIVEFXSLOTS EAX40SOURCE_DEFAULTACTIVEFXSLOTID;
extern const EAX40ACTIVEFXSLOTS EAX40SOURCE_DEFAULTACTIVEFXSLOTID;
extern const EAX50ACTIVEFXSLOTS EAX50SOURCE_3DDEFAULTACTIVEFXSLOTID;

View File

@ -2,6 +2,7 @@
#define EAX_EAX_CALL_INCLUDED
#include "AL/al.h"
#include "alnumeric.h"
#include "alspan.h"
#include "api.h"
#include "fx_slot_index.h"
@ -48,16 +49,20 @@ public:
return *static_cast<TValue*>(property_buffer_);
}
template<typename TException, typename TValue>
template<typename TValue>
al::span<TValue> get_values(size_t max_count) const
{
if (max_count == 0 || property_size_ < static_cast<ALuint>(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};
}
template<typename TValue>
al::span<TValue> get_values() const
{
if (property_size_ < static_cast<ALuint>(sizeof(TValue)))
{
fail_too_small();
}
const auto count = property_size_ / sizeof(TValue);
return al::span<TValue>{static_cast<TValue*>(property_buffer_), count};
return get_values<TValue>(~size_t{});
}
template<typename TException, typename TValue>

View File

@ -6,22 +6,14 @@
#include <string>
#include <type_traits>
struct EaxAlLowPassParam
{
struct EaxAlLowPassParam {
float gain;
float gain_hf;
}; // EaxAlLowPassParam
};
void eax_log_exception(const char* message = nullptr) noexcept;
void eax_log_exception(
const char* message = nullptr) noexcept;
template<
typename TException,
typename TValue
>
template<typename TException, typename TValue>
void eax_validate_range(
const char* value_name,
const TValue& value,
@ -29,9 +21,7 @@ void eax_validate_range(
const TValue& max_value)
{
if (value >= min_value && value <= max_value)
{
return;
}
const auto message =
std::string{value_name} +
@ -43,60 +33,38 @@ void eax_validate_range(
throw TException{message.c_str()};
}
namespace detail {
namespace detail
{
template<
typename T
>
struct EaxIsBitFieldStruct
{
template<typename T>
struct EaxIsBitFieldStruct {
private:
using yes = std::true_type;
using no = std::false_type;
template<
typename U
>
template<typename U>
static auto test(int) -> decltype(std::declval<typename U::EaxIsBitFieldStruct>(), yes{});
template<
typename
>
template<typename>
static no test(...);
public:
static constexpr auto value = std::is_same<decltype(test<T>(0)), yes>::value;
}; // EaxIsBitFieldStruct
};
template<
typename T,
typename TValue
>
inline bool eax_bit_fields_are_equal(
const T& lhs,
const T& rhs) noexcept
template<typename T, typename TValue>
inline bool eax_bit_fields_are_equal(const T& lhs, const T& rhs) noexcept
{
static_assert(sizeof(T) == sizeof(TValue), "Invalid type size.");
return reinterpret_cast<const TValue&>(lhs) == reinterpret_cast<const TValue&>(rhs);
}
} // namespace detail
template<
typename T,
std::enable_if_t<detail::EaxIsBitFieldStruct<T>::value, int> = 0
>
inline bool operator==(
const T& lhs,
const T& rhs) noexcept
inline bool operator==(const T& lhs, const T& rhs) noexcept
{
using Value = std::conditional_t<
sizeof(T) == 1,
@ -107,13 +75,9 @@ inline bool operator==(
std::conditional_t<
sizeof(T) == 4,
std::uint32_t,
void
>
>
>;
void>>>;
static_assert(!std::is_same<Value, void>::value, "Unsupported type.");
return detail::eax_bit_fields_are_equal<T, Value>(lhs, rhs);
}
@ -121,12 +85,9 @@ template<
typename T,
std::enable_if_t<detail::EaxIsBitFieldStruct<T>::value, int> = 0
>
inline bool operator!=(
const T& lhs,
const T& rhs) noexcept
inline bool operator!=(const T& lhs, const T& rhs) noexcept
{
return !(lhs == rhs);
}
#endif // !EAX_UTILS_INCLUDED

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -337,6 +337,7 @@ ALenum ALCcontext::eax_eax_set(
property_source_id,
property_value,
property_value_size);
eax_version_ = call.get_version();
eax_initialize(call);
eax_unlock_legacy_fx_slots(call);
@ -380,6 +381,7 @@ ALenum ALCcontext::eax_eax_get(
property_source_id,
property_value,
property_value_size);
eax_version_ = call.get_version();
eax_initialize(call);
eax_unlock_legacy_fx_slots(call);
@ -407,7 +409,7 @@ ALenum ALCcontext::eax_eax_get(
void ALCcontext::eax_update_filters()
{
ForEachSource(this, std::mem_fn(&ALsource::eax_update_filters));
ForEachSource(this, [](ALsource& source){ source.eax_commit(); });
}
void ALCcontext::eax_commit_and_update_sources()
@ -627,15 +629,11 @@ void ALCcontext::eax_dispatch_fx_slot(const EaxCall& call)
void ALCcontext::eax_dispatch_source(const EaxCall& call)
{
const auto source_id = call.get_property_al_name();
std::lock_guard<std::mutex> source_lock{mSourceLock};
const auto source = ALsource::eax_lookup_source(*this, source_id);
if (!source)
{
if (source == nullptr)
eax_fail("Source not found.");
}
source->eax_dispatch(call);
}
@ -749,7 +747,6 @@ void ALCcontext::eax_get(const EaxCall& call)
void ALCcontext::eax_set_primary_fx_slot_id()
{
eax_previous_primary_fx_slot_index_ = eax_primary_fx_slot_index_;
eax_primary_fx_slot_index_ = eax_.context.guidPrimaryFXSlotID;
}
@ -786,7 +783,6 @@ void ALCcontext::eax_set_context()
void ALCcontext::eax_initialize_fx_slots(const EaxCall& call)
{
eax_fx_slots_.initialize(call, *this);
eax_previous_primary_fx_slot_index_ = eax_.context.guidPrimaryFXSlotID;
eax_primary_fx_slot_index_ = eax_.context.guidPrimaryFXSlotID;
}
@ -802,7 +798,7 @@ void ALCcontext::eax_update_sources()
{
std::unique_lock<std::mutex> source_lock{mSourceLock};
auto update_source = [this](ALsource &source)
{ source.eax_update(eax_context_shared_dirty_flags_); };
{ source.eax_commit(); };
ForEachSource(this, update_source);
}
@ -1130,7 +1126,6 @@ void ALCcontext::eax_apply_deferred()
if (eax_context_dirty_flags_.guidPrimaryFXSlotID)
{
eax_context_shared_dirty_flags_.primary_fx_slot_id = true;
eax_set_primary_fx_slot_id();
}
@ -1154,12 +1149,11 @@ void ALCcontext::eax_apply_deferred()
eax_set_macro_fx_factor();
}
if (eax_context_shared_dirty_flags_ != EaxContextSharedDirtyFlags{})
if (eax_context_dirty_flags_.guidPrimaryFXSlotID)
{
eax_update_sources();
}
eax_context_shared_dirty_flags_ = EaxContextSharedDirtyFlags{};
eax_context_dirty_flags_ = ContextDirtyFlags{};
}

View File

@ -26,16 +26,6 @@
#include "al/eax/utils.h"
using EaxContextSharedDirtyFlagsValue = std::uint_least8_t;
struct EaxContextSharedDirtyFlags
{
using EaxIsBitFieldStruct = bool;
EaxContextSharedDirtyFlagsValue primary_fx_slot_id : 1;
}; // EaxContextSharedDirtyFlags
using ContextDirtyFlagsValue = std::uint_least8_t;
struct ContextDirtyFlags
@ -224,6 +214,7 @@ public:
void eax_uninitialize() noexcept;
int eax_get_version() const noexcept { return eax_version_; }
ALenum eax_eax_set(
const GUID* property_set_id,
@ -248,8 +239,6 @@ public:
void eax_set_last_error() noexcept;
EaxFxSlotIndex eax_get_previous_primary_fx_slot_index() const noexcept
{ return eax_previous_primary_fx_slot_index_; }
EaxFxSlotIndex eax_get_primary_fx_slot_index() const noexcept
{ return eax_primary_fx_slot_index_; }
@ -275,12 +264,10 @@ private:
long eax_last_error_{};
unsigned long eax_speaker_config_{};
EaxFxSlotIndex eax_previous_primary_fx_slot_index_{};
EaxFxSlotIndex eax_primary_fx_slot_index_{};
EaxFxSlots eax_fx_slots_{};
EaxContextSharedDirtyFlags eax_context_shared_dirty_flags_{};
int eax_version_{};
Eax eax_{};
Eax eax_d_{};
EAXSESSIONPROPERTIES eax_session_{};