aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
Diffstat (limited to 'al')
-rw-r--r--al/auxeffectslot.h16
-rw-r--r--al/eax/api.h10
-rw-r--r--al/eax/call.h42
-rw-r--r--al/eax/fx_slots.h9
-rw-r--r--al/effect.cpp14
-rw-r--r--al/effect.h10
-rw-r--r--al/effects/effects.h2
-rw-r--r--al/event.cpp2
-rw-r--r--al/source.cpp31
-rw-r--r--al/source.h8
10 files changed, 72 insertions, 72 deletions
diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h
index 36216022..bfd4038e 100644
--- a/al/auxeffectslot.h
+++ b/al/auxeffectslot.h
@@ -89,12 +89,12 @@ struct ALeffectslot {
public:
void eax_initialize(ALCcontext& al_context, EaxFxSlotIndexValue index);
- EaxFxSlotIndexValue eax_get_index() const noexcept { return eax_fx_slot_index_; }
- const EAX50FXSLOTPROPERTIES& eax_get_eax_fx_slot() const noexcept
+ [[nodiscard]] auto eax_get_index() const noexcept -> EaxFxSlotIndexValue { return eax_fx_slot_index_; }
+ [[nodiscard]] auto eax_get_eax_fx_slot() const noexcept -> const EAX50FXSLOTPROPERTIES&
{ return eax_; }
// Returns `true` if all sources should be updated, or `false` otherwise.
- bool eax_dispatch(const EaxCall& call)
+ [[nodiscard]] auto eax_dispatch(const EaxCall& call) -> bool
{ return call.is_get() ? eax_get(call) : eax_set(call); }
void eax_commit();
@@ -282,14 +282,14 @@ private:
dst = src;
}
- constexpr bool eax4_fx_slot_is_legacy() const noexcept
+ [[nodiscard]] constexpr auto eax4_fx_slot_is_legacy() const noexcept -> bool
{ return eax_fx_slot_index_ < 2; }
void eax4_fx_slot_ensure_unlocked() const;
- static ALenum eax_get_efx_effect_type(const GUID& guid);
- const GUID& eax_get_eax_default_effect_guid() const noexcept;
- long eax_get_eax_default_lock() const noexcept;
+ [[nodiscard]] static auto eax_get_efx_effect_type(const GUID& guid) -> ALenum;
+ [[nodiscard]] auto eax_get_eax_default_effect_guid() const noexcept -> const GUID&;
+ [[nodiscard]] auto eax_get_eax_default_lock() const noexcept -> long;
void eax4_fx_slot_set_defaults(Eax4Props& props) noexcept;
void eax5_fx_slot_set_defaults(Eax5Props& props) noexcept;
@@ -312,7 +312,7 @@ private:
void eax4_fx_slot_set_all(const EaxCall& call);
void eax5_fx_slot_set_all(const EaxCall& call);
- bool eax_fx_slot_should_update_sources() const noexcept;
+ [[nodiscard]] auto eax_fx_slot_should_update_sources() const noexcept -> bool;
// Returns `true` if all sources should be updated, or `false` otherwise.
bool eax4_fx_slot_set(const EaxCall& call);
diff --git a/al/eax/api.h b/al/eax/api.h
index 18d93ef8..038fdf75 100644
--- a/al/eax/api.h
+++ b/al/eax/api.h
@@ -22,12 +22,12 @@
#ifndef _WIN32
-typedef struct _GUID {
+using GUID = struct _GUID {
std::uint32_t Data1;
std::uint16_t Data2;
std::uint16_t Data3;
- std::uint8_t Data4[8];
-} GUID;
+ std::array<std::uint8_t,8> Data4;
+};
inline bool operator==(const GUID& lhs, const GUID& rhs) noexcept
{ return std::memcmp(&lhs, &rhs, sizeof(GUID)) == 0; }
@@ -654,11 +654,11 @@ struct EAXSPEAKERLEVELPROPERTIES {
}; // EAXSPEAKERLEVELPROPERTIES
struct EAX40ACTIVEFXSLOTS {
- GUID guidActiveFXSlots[EAX40_MAX_ACTIVE_FXSLOTS];
+ std::array<GUID,EAX40_MAX_ACTIVE_FXSLOTS> guidActiveFXSlots;
}; // EAX40ACTIVEFXSLOTS
struct EAX50ACTIVEFXSLOTS {
- GUID guidActiveFXSlots[EAX50_MAX_ACTIVE_FXSLOTS];
+ std::array<GUID,EAX50_MAX_ACTIVE_FXSLOTS> guidActiveFXSlots;
}; // EAX50ACTIVEFXSLOTS
// Use this structure for EAXSOURCE_OBSTRUCTIONPARAMETERS property.
diff --git a/al/eax/call.h b/al/eax/call.h
index 45ff328c..04e94f3e 100644
--- a/al/eax/call.h
+++ b/al/eax/call.h
@@ -31,16 +31,16 @@ public:
ALvoid* property_buffer,
ALuint property_size);
- 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; }
+ [[nodiscard]] auto is_get() const noexcept -> bool { return mCallType == EaxCallType::get; }
+ [[nodiscard]] auto is_deferred() const noexcept -> bool { return mIsDeferred; }
+ [[nodiscard]] auto get_version() const noexcept -> int { return mVersion; }
+ [[nodiscard]] auto get_property_set_id() const noexcept -> EaxCallPropertySetId { return mPropertySetId; }
+ [[nodiscard]] auto get_property_id() const noexcept -> ALuint { return mPropertyId; }
+ [[nodiscard]] auto get_property_al_name() const noexcept -> ALuint { return mPropertySourceId; }
+ [[nodiscard]] auto get_fx_slot_index() const noexcept -> EaxFxSlotIndex { return mFxSlotIndex; }
template<typename TException, typename TValue>
- TValue& get_value() const
+ [[nodiscard]] auto get_value() const -> TValue&
{
if(mPropertyBufferSize < sizeof(TValue))
fail_too_small();
@@ -49,7 +49,7 @@ public:
}
template<typename TValue>
- al::span<TValue> get_values(size_t max_count) const
+ [[nodiscard]] auto get_values(size_t max_count) const -> al::span<TValue>
{
if(max_count == 0 || mPropertyBufferSize < sizeof(TValue))
fail_too_small();
@@ -59,28 +59,28 @@ public:
}
template<typename TValue>
- al::span<TValue> get_values() const
+ [[nodiscard]] auto get_values() const -> al::span<TValue>
{
return get_values<TValue>(~0_uz);
}
template<typename TException, typename TValue>
- void set_value(const TValue& value) const
+ auto set_value(const TValue& value) const -> void
{
get_value<TException, TValue>() = value;
}
private:
- const EaxCallType mCallType;
- int mVersion;
- EaxFxSlotIndex mFxSlotIndex;
- EaxCallPropertySetId mPropertySetId;
- bool mIsDeferred;
-
- const ALuint mPropertyId;
- const ALuint mPropertySourceId;
- ALvoid*const mPropertyBuffer;
- const ALuint mPropertyBufferSize;
+ 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();
diff --git a/al/eax/fx_slots.h b/al/eax/fx_slots.h
index 18b2d3ad..b7ed1031 100644
--- a/al/eax/fx_slots.h
+++ b/al/eax/fx_slots.h
@@ -25,11 +25,9 @@ public:
}
- const ALeffectslot& get(
- EaxFxSlotIndex index) const;
+ [[nodiscard]] auto get(EaxFxSlotIndex index) const -> const ALeffectslot&;
- ALeffectslot& get(
- EaxFxSlotIndex index);
+ [[nodiscard]] auto get(EaxFxSlotIndex index) -> ALeffectslot&;
private:
using Items = std::array<EaxAlEffectSlotUPtr, EAX_MAX_FXSLOTS>;
@@ -39,8 +37,7 @@ private:
[[noreturn]]
- static void fail(
- const char* message);
+ static void fail(const char* message);
void initialize_fx_slots(ALCcontext& al_context);
}; // EaxFxSlots
diff --git a/al/effect.cpp b/al/effect.cpp
index 3e48e91b..e99226c8 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -58,7 +58,7 @@
#include "eax/exception.h"
#endif // ALSOFT_EAX
-const EffectList gEffectList[16]{
+const std::array<EffectList,16> gEffectList{{
{ "eaxreverb", EAXREVERB_EFFECT, AL_EFFECT_EAXREVERB },
{ "reverb", REVERB_EFFECT, AL_EFFECT_REVERB },
{ "autowah", AUTOWAH_EFFECT, AL_EFFECT_AUTOWAH },
@@ -75,9 +75,7 @@ const EffectList gEffectList[16]{
{ "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT },
{ "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_DIALOGUE },
{ "convolution", CONVOLUTION_EFFECT, AL_EFFECT_CONVOLUTION_SOFT },
-};
-
-bool DisabledEffects[MAX_EFFECTS];
+}};
effect_exception::effect_exception(ALenum code, const char *msg, ...) : mErrorCode{code}
@@ -328,7 +326,7 @@ FORCE_ALIGN void AL_APIENTRY alEffectiDirect(ALCcontext *context, ALuint effect,
{
for(const EffectList &effectitem : gEffectList)
{
- if(value == effectitem.val && !DisabledEffects[effectitem.type])
+ if(value == effectitem.val && !DisabledEffects.test(effectitem.type))
{
isOk = true;
break;
@@ -687,9 +685,9 @@ void LoadReverbPreset(const char *name, ALeffect *effect)
return;
}
- if(!DisabledEffects[EAXREVERB_EFFECT])
+ if(!DisabledEffects.test(EAXREVERB_EFFECT))
InitEffectParams(effect, AL_EFFECT_EAXREVERB);
- else if(!DisabledEffects[REVERB_EFFECT])
+ else if(!DisabledEffects.test(REVERB_EFFECT))
InitEffectParams(effect, AL_EFFECT_REVERB);
else
InitEffectParams(effect, AL_EFFECT_NULL);
@@ -742,7 +740,7 @@ bool IsValidEffectType(ALenum type) noexcept
for(const auto &effect_item : gEffectList)
{
- if(type == effect_item.val && !DisabledEffects[effect_item.type])
+ if(type == effect_item.val && !DisabledEffects.test(effect_item.type))
return true;
}
return false;
diff --git a/al/effect.h b/al/effect.h
index 27e9dd72..7c5c40dc 100644
--- a/al/effect.h
+++ b/al/effect.h
@@ -1,6 +1,8 @@
#ifndef AL_EFFECT_H
#define AL_EFFECT_H
+#include <array>
+#include <bitset>
#include <string_view>
#include "AL/al.h"
@@ -29,16 +31,14 @@ enum {
MAX_EFFECTS
};
-extern bool DisabledEffects[MAX_EFFECTS];
-
-extern float ReverbBoost;
+inline std::bitset<MAX_EFFECTS> DisabledEffects;
struct EffectList {
const char name[16];
- int type;
+ ALuint type;
ALenum val;
};
-extern const EffectList gEffectList[16];
+extern const std::array<EffectList,16> gEffectList;
struct ALeffect {
diff --git a/al/effects/effects.h b/al/effects/effects.h
index f30f256a..66fc8c44 100644
--- a/al/effects/effects.h
+++ b/al/effects/effects.h
@@ -24,7 +24,7 @@ public:
effect_exception(ALenum code, const char *msg, ...);
~effect_exception() override;
- ALenum errorCode() const noexcept { return mErrorCode; }
+ [[nodiscard]] auto errorCode() const noexcept -> ALenum { return mErrorCode; }
};
diff --git a/al/event.cpp b/al/event.cpp
index 8b76ceff..95b07dc2 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -118,7 +118,7 @@ int EventThread(ALCcontext *context)
};
auto proc_disconnect = [context,enabledevts](AsyncDisconnectEvent &evt)
{
- const std::string_view message{evt.msg};
+ const std::string_view message{evt.msg.data()};
context->debugMessage(DebugSource::System, DebugType::Error, 0,
DebugSeverity::High, message);
diff --git a/al/source.cpp b/al/source.cpp
index c9ec8f21..9c449434 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -3917,27 +3917,30 @@ void ALsource::eax4_translate(const Eax4Props& src, Eax5Props& dst) noexcept
// Active FX slots.
//
- for (auto i = 0; i < EAX50_MAX_ACTIVE_FXSLOTS; ++i) {
+ for(size_t i{0};i < EAX50_MAX_ACTIVE_FXSLOTS;++i)
+ {
auto& dst_id = dst.active_fx_slots.guidActiveFXSlots[i];
- if (i < EAX40_MAX_ACTIVE_FXSLOTS) {
+ if(i < EAX40_MAX_ACTIVE_FXSLOTS)
+ {
const auto& src_id = src.active_fx_slots.guidActiveFXSlots[i];
- if (src_id == EAX_NULL_GUID)
+ if(src_id == EAX_NULL_GUID)
dst_id = EAX_NULL_GUID;
- else if (src_id == EAX_PrimaryFXSlotID)
+ else if(src_id == EAX_PrimaryFXSlotID)
dst_id = EAX_PrimaryFXSlotID;
- else if (src_id == EAXPROPERTYID_EAX40_FXSlot0)
+ else if(src_id == EAXPROPERTYID_EAX40_FXSlot0)
dst_id = EAXPROPERTYID_EAX50_FXSlot0;
- else if (src_id == EAXPROPERTYID_EAX40_FXSlot1)
+ else if(src_id == EAXPROPERTYID_EAX40_FXSlot1)
dst_id = EAXPROPERTYID_EAX50_FXSlot1;
- else if (src_id == EAXPROPERTYID_EAX40_FXSlot2)
+ else if(src_id == EAXPROPERTYID_EAX40_FXSlot2)
dst_id = EAXPROPERTYID_EAX50_FXSlot2;
- else if (src_id == EAXPROPERTYID_EAX40_FXSlot3)
+ else if(src_id == EAXPROPERTYID_EAX40_FXSlot3)
dst_id = EAXPROPERTYID_EAX50_FXSlot3;
else
assert(false && "Unknown active FX slot ID.");
- } else
+ }
+ else
dst_id = EAX_NULL_GUID;
}
@@ -4359,7 +4362,7 @@ void ALsource::eax4_set(const EaxCall& call, Eax4Props& props)
break;
case EAXSOURCE_ACTIVEFXSLOTID:
- eax4_defer_active_fx_slot_id(call, props.active_fx_slots.guidActiveFXSlots);
+ eax4_defer_active_fx_slot_id(call, al::span{props.active_fx_slots.guidActiveFXSlots});
break;
default:
@@ -4440,7 +4443,7 @@ void ALsource::eax5_set(const EaxCall& call, Eax5Props& props)
break;
case EAXSOURCE_ACTIVEFXSLOTID:
- eax5_defer_active_fx_slot_id(call, props.active_fx_slots.guidActiveFXSlots);
+ eax5_defer_active_fx_slot_id(call, al::span{props.active_fx_slots.guidActiveFXSlots});
break;
case EAXSOURCE_MACROFXFACTOR:
@@ -4730,7 +4733,8 @@ void ALsource::eax4_get(const EaxCall& call, const Eax4Props& props)
break;
case EAXSOURCE_ACTIVEFXSLOTID:
- eax_get_active_fx_slot_id(call, props.active_fx_slots.guidActiveFXSlots, EAX40_MAX_ACTIVE_FXSLOTS);
+ eax_get_active_fx_slot_id(call, props.active_fx_slots.guidActiveFXSlots.data(),
+ EAX40_MAX_ACTIVE_FXSLOTS);
break;
default:
@@ -4802,7 +4806,8 @@ void ALsource::eax5_get(const EaxCall& call, const Eax5Props& props)
break;
case EAXSOURCE_ACTIVEFXSLOTID:
- eax_get_active_fx_slot_id(call, props.active_fx_slots.guidActiveFXSlots, EAX50_MAX_ACTIVE_FXSLOTS);
+ eax_get_active_fx_slot_id(call, props.active_fx_slots.guidActiveFXSlots.data(),
+ EAX50_MAX_ACTIVE_FXSLOTS);
break;
case EAXSOURCE_MACROFXFACTOR:
diff --git a/al/source.h b/al/source.h
index c7694f83..26d425ef 100644
--- a/al/source.h
+++ b/al/source.h
@@ -978,21 +978,21 @@ private:
}
template<typename TValidator, size_t TIdCount>
- void eax_defer_active_fx_slot_id(const EaxCall& call, GUID (&dst_ids)[TIdCount])
+ void eax_defer_active_fx_slot_id(const EaxCall& call, const al::span<GUID,TIdCount> dst_ids)
{
const auto src_ids = call.get_values<const GUID>(TIdCount);
std::for_each(src_ids.cbegin(), src_ids.cend(), TValidator{});
- std::uninitialized_copy(src_ids.cbegin(), src_ids.cend(), dst_ids);
+ std::uninitialized_copy(src_ids.cbegin(), src_ids.cend(), dst_ids.begin());
}
template<size_t TIdCount>
- void eax4_defer_active_fx_slot_id(const EaxCall& call, GUID (&dst_ids)[TIdCount])
+ void eax4_defer_active_fx_slot_id(const EaxCall& call, const al::span<GUID,TIdCount> dst_ids)
{
eax_defer_active_fx_slot_id<Eax4ActiveFxSlotIdValidator>(call, dst_ids);
}
template<size_t TIdCount>
- void eax5_defer_active_fx_slot_id(const EaxCall& call, GUID (&dst_ids)[TIdCount])
+ void eax5_defer_active_fx_slot_id(const EaxCall& call, const al::span<GUID,TIdCount> dst_ids)
{
eax_defer_active_fx_slot_id<Eax5ActiveFxSlotIdValidator>(call, dst_ids);
}