aboutsummaryrefslogtreecommitdiffstats
path: root/al/eax
diff options
context:
space:
mode:
Diffstat (limited to 'al/eax')
-rw-r--r--al/eax/api.cpp2
-rw-r--r--al/eax/api.h19
-rw-r--r--al/eax/call.h17
-rw-r--r--al/eax/utils.h69
4 files changed, 43 insertions, 64 deletions
diff --git a/al/eax/api.cpp b/al/eax/api.cpp
index 34ba554f..a1e9d3e1 100644
--- a/al/eax/api.cpp
+++ b/al/eax/api.cpp
@@ -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,
diff --git a/al/eax/api.h b/al/eax/api.h
index f4419ddb..a9b0a50f 100644
--- a/al/eax/api.h
+++ b/al/eax/api.h
@@ -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;
diff --git a/al/eax/call.h b/al/eax/call.h
index d491d6f9..9c2706c3 100644
--- a/al/eax/call.h
+++ b/al/eax/call.h
@@ -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,18 +49,22 @@ public:
return *static_cast<TValue*>(property_buffer_);
}
- template<typename TException, typename TValue>
- al::span<TValue> get_values() const
+ template<typename TValue>
+ al::span<TValue> get_values(size_t max_count) const
{
- if (property_size_ < static_cast<ALuint>(sizeof(TValue)))
- {
+ if (max_count == 0 || property_size_ < static_cast<ALuint>(sizeof(TValue)))
fail_too_small();
- }
- const auto count = property_size_ / sizeof(TValue);
+ 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
+ {
+ return get_values<TValue>(~size_t{});
+ }
+
template<typename TException, typename TValue>
void set_value(const TValue& value) const
{
diff --git a/al/eax/utils.h b/al/eax/utils.h
index d3d4a196..5a8fdd64 100644
--- a/al/eax/utils.h
+++ b/al/eax/utils.h
@@ -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