From b6a68e8d510610e181d638ff993e327059bd6018 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 3 Dec 2023 23:36:07 -0800 Subject: Remove some unnecessary atomic wrappers --- al/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'al/buffer.h') diff --git a/al/buffer.h b/al/buffer.h index f936cf98..cb864aff 100644 --- a/al/buffer.h +++ b/al/buffer.h @@ -43,7 +43,7 @@ struct ALbuffer : public BufferStorage { ALuint mLoopEnd{0u}; /* Number of times buffer was attached to a source (deletion can only occur when 0) */ - RefCount ref{0u}; + std::atomic ref{0u}; /* Self ID */ ALuint id{0}; -- cgit v1.2.3 From 41266e96aeb0cac54d05a9e57dcea0990933dd33 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 15 Dec 2023 18:54:53 -0800 Subject: Remove unnecessary macro parameter lists --- al/buffer.h | 2 +- al/effect.h | 2 +- al/filter.h | 2 +- al/listener.h | 2 +- al/source.h | 4 ++-- common/almalloc.h | 10 +++++----- common/flexarray.h | 2 +- core/device.h | 2 +- core/hrtf.h | 2 +- core/mastering.h | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) (limited to 'al/buffer.h') diff --git a/al/buffer.h b/al/buffer.h index cb864aff..2bcab6cf 100644 --- a/al/buffer.h +++ b/al/buffer.h @@ -50,7 +50,7 @@ struct ALbuffer : public BufferStorage { static void SetName(ALCcontext *context, ALuint id, std::string_view name); - DISABLE_ALLOC() + DISABLE_ALLOC #ifdef ALSOFT_EAX EaxStorage eax_x_ram_mode{EaxStorage::Automatic}; diff --git a/al/effect.h b/al/effect.h index fef03475..71fe9c87 100644 --- a/al/effect.h +++ b/al/effect.h @@ -54,7 +54,7 @@ struct ALeffect { static void SetName(ALCcontext *context, ALuint id, std::string_view name); - DISABLE_ALLOC() + DISABLE_ALLOC }; void InitEffect(ALeffect *effect); diff --git a/al/filter.h b/al/filter.h index 505900d4..b87e7f03 100644 --- a/al/filter.h +++ b/al/filter.h @@ -51,7 +51,7 @@ struct ALfilter { static void SetName(ALCcontext *context, ALuint id, std::string_view name); - DISABLE_ALLOC() + DISABLE_ALLOC }; #endif diff --git a/al/listener.h b/al/listener.h index 81532877..a50f118a 100644 --- a/al/listener.h +++ b/al/listener.h @@ -18,7 +18,7 @@ struct ALlistener { float Gain{1.0f}; float mMetersPerUnit{AL_DEFAULT_METERS_PER_UNIT}; - DISABLE_ALLOC() + DISABLE_ALLOC }; #endif diff --git a/al/source.h b/al/source.h index 3fd43a5c..69bedda3 100644 --- a/al/source.h +++ b/al/source.h @@ -46,7 +46,7 @@ inline bool sBufferSubDataCompat{false}; struct ALbufferQueueItem : public VoiceBufferItem { ALbuffer *mBuffer{nullptr}; - DISABLE_ALLOC() + DISABLE_ALLOC }; @@ -159,7 +159,7 @@ struct ALsource { static void SetName(ALCcontext *context, ALuint id, std::string_view name); - DISABLE_ALLOC() + DISABLE_ALLOC #ifdef ALSOFT_EAX public: diff --git a/common/almalloc.h b/common/almalloc.h index 8a976aae..b3d8dd58 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -20,7 +20,7 @@ void *al_malloc(size_t alignment, size_t size); void *al_calloc(size_t alignment, size_t size); -#define DISABLE_ALLOC() \ +#define DISABLE_ALLOC \ void *operator new(size_t) = delete; \ void *operator new[](size_t) = delete; \ void operator delete(void*) noexcept = delete; \ @@ -39,9 +39,9 @@ void *al_calloc(size_t alignment, size_t size); void operator delete(void *block) noexcept { al_free(block); } \ void operator delete[](void *block) noexcept { operator delete(block); } -#define DEF_PLACE_NEWDEL() \ - void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; } \ - void *operator new[](size_t /*size*/, void *ptr) noexcept { return ptr; } \ +#define DEF_PLACE_NEWDEL \ + void *operator new(size_t) = delete; \ + void *operator new[](size_t) = delete; \ void operator delete(void *block, void*) noexcept { al_free(block); } \ void operator delete(void *block) noexcept { al_free(block); } \ void operator delete[](void *block, void*) noexcept { al_free(block); } \ @@ -65,7 +65,7 @@ enum FamCount : size_t { }; throw std::bad_alloc(); \ } \ void *operator new[](size_t /*size*/) = delete; \ - void operator delete(void *block, FamCount) { al_free(block); } \ + void operator delete(void *block, FamCount) noexcept { al_free(block); } \ void operator delete(void *block) noexcept { al_free(block); } \ void operator delete[](void* /*block*/) = delete; diff --git a/common/flexarray.h b/common/flexarray.h index d02a7342..c317bfbe 100644 --- a/common/flexarray.h +++ b/common/flexarray.h @@ -105,7 +105,7 @@ struct FlexArray { [[nodiscard]] auto rend() const noexcept -> const_reverse_iterator { return begin(); } [[nodiscard]] auto crend() const noexcept -> const_reverse_iterator { return cbegin(); } - DEF_PLACE_NEWDEL() + DEF_PLACE_NEWDEL }; } // namespace al diff --git a/core/device.h b/core/device.h index 668779fa..93d64aef 100644 --- a/core/device.h +++ b/core/device.h @@ -380,7 +380,7 @@ struct DeviceBase { [[nodiscard]] auto channelIdxByName(Channel chan) const noexcept -> uint8_t { return RealOut.ChannelIndex[chan]; } - DISABLE_ALLOC() + DISABLE_ALLOC private: uint renderSamples(const uint numSamples); diff --git a/core/hrtf.h b/core/hrtf.h index c5dc6475..e0263493 100644 --- a/core/hrtf.h +++ b/core/hrtf.h @@ -47,7 +47,7 @@ struct HrtfStore { void add_ref(); void dec_ref(); - DEF_PLACE_NEWDEL() + DEF_PLACE_NEWDEL }; using HrtfStorePtr = al::intrusive_ptr; diff --git a/core/mastering.h b/core/mastering.h index 0d4f5fa1..35480176 100644 --- a/core/mastering.h +++ b/core/mastering.h @@ -66,7 +66,7 @@ struct Compressor { void process(const uint SamplesToDo, FloatBufferLine *OutBuffer); [[nodiscard]] auto getLookAhead() const noexcept -> int { return static_cast(mLookAhead); } - DEF_PLACE_NEWDEL() + DEF_PLACE_NEWDEL /** * The compressor is initialized with the following settings: -- cgit v1.2.3 From cfab14287405a0d34f6a0fec1336f46415728fcf Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 29 Dec 2023 09:05:47 -0800 Subject: Move struct definitions to more appropriate headers --- al/auxeffectslot.h | 18 ++++++++++++++++++ al/buffer.h | 17 +++++++++++++++++ al/effect.h | 18 ++++++++++++++++++ al/filter.h | 18 ++++++++++++++++++ al/source.h | 16 ++++++++++++++++ alc/context.h | 33 ++------------------------------- alc/device.cpp | 3 +++ alc/device.h | 49 +++---------------------------------------------- 8 files changed, 95 insertions(+), 77 deletions(-) (limited to 'al/buffer.h') diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index fc474bb4..6946591e 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "AL/al.h" @@ -12,6 +13,7 @@ #include "alc/device.h" #include "alc/effects/base.h" #include "almalloc.h" +#include "alnumeric.h" #include "atomic.h" #include "core/effectslot.h" #include "intrusive_ptr.h" @@ -367,4 +369,20 @@ EaxAlEffectSlotUPtr eax_create_al_effect_slot(ALCcontext& context); void eax_delete_al_effect_slot(ALCcontext& context, ALeffectslot& effect_slot); #endif // ALSOFT_EAX +struct EffectSlotSubList { + uint64_t FreeMask{~0_u64}; + gsl::owner*> EffectSlots{nullptr}; + + EffectSlotSubList() noexcept = default; + EffectSlotSubList(const EffectSlotSubList&) = delete; + EffectSlotSubList(EffectSlotSubList&& rhs) noexcept + : FreeMask{rhs.FreeMask}, EffectSlots{rhs.EffectSlots} + { rhs.FreeMask = ~0_u64; rhs.EffectSlots = nullptr; } + ~EffectSlotSubList(); + + EffectSlotSubList& operator=(const EffectSlotSubList&) = delete; + EffectSlotSubList& operator=(EffectSlotSubList&& rhs) noexcept + { std::swap(FreeMask, rhs.FreeMask); std::swap(EffectSlots, rhs.EffectSlots); return *this; } +}; + #endif diff --git a/al/buffer.h b/al/buffer.h index 2bcab6cf..b9e59d68 100644 --- a/al/buffer.h +++ b/al/buffer.h @@ -3,12 +3,14 @@ #include #include +#include #include #include "AL/al.h" #include "alc/inprogext.h" #include "almalloc.h" +#include "alnumeric.h" #include "atomic.h" #include "core/buffer_storage.h" #include "vector.h" @@ -58,4 +60,19 @@ struct ALbuffer : public BufferStorage { #endif // ALSOFT_EAX }; +struct BufferSubList { + uint64_t FreeMask{~0_u64}; + gsl::owner*> Buffers{nullptr}; + + BufferSubList() noexcept = default; + BufferSubList(const BufferSubList&) = delete; + BufferSubList(BufferSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Buffers{rhs.Buffers} + { rhs.FreeMask = ~0_u64; rhs.Buffers = nullptr; } + ~BufferSubList(); + + BufferSubList& operator=(const BufferSubList&) = delete; + BufferSubList& operator=(BufferSubList&& rhs) noexcept + { std::swap(FreeMask, rhs.FreeMask); std::swap(Buffers, rhs.Buffers); return *this; } +}; + #endif diff --git a/al/effect.h b/al/effect.h index 820c7d28..8f069bee 100644 --- a/al/effect.h +++ b/al/effect.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "AL/al.h" @@ -10,6 +11,8 @@ #include "al/effects/effects.h" #include "alc/effects/base.h" +#include "almalloc.h" +#include "alnumeric.h" enum { @@ -61,4 +64,19 @@ void LoadReverbPreset(const char *name, ALeffect *effect); bool IsValidEffectType(ALenum type) noexcept; +struct EffectSubList { + uint64_t FreeMask{~0_u64}; + gsl::owner*> Effects{nullptr}; /* 64 */ + + EffectSubList() noexcept = default; + EffectSubList(const EffectSubList&) = delete; + EffectSubList(EffectSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Effects{rhs.Effects} + { rhs.FreeMask = ~0_u64; rhs.Effects = nullptr; } + ~EffectSubList(); + + EffectSubList& operator=(const EffectSubList&) = delete; + EffectSubList& operator=(EffectSubList&& rhs) noexcept + { std::swap(FreeMask, rhs.FreeMask); std::swap(Effects, rhs.Effects); return *this; } +}; + #endif diff --git a/al/filter.h b/al/filter.h index b87e7f03..20d5e012 100644 --- a/al/filter.h +++ b/al/filter.h @@ -1,6 +1,8 @@ #ifndef AL_FILTER_H #define AL_FILTER_H +#include +#include #include #include @@ -9,6 +11,7 @@ #include "AL/alext.h" #include "almalloc.h" +#include "alnumeric.h" #define LOWPASSFREQREF 5000.0f #define HIGHPASSFREQREF 250.0f @@ -54,4 +57,19 @@ struct ALfilter { DISABLE_ALLOC }; +struct FilterSubList { + uint64_t FreeMask{~0_u64}; + gsl::owner*> Filters{nullptr}; + + FilterSubList() noexcept = default; + FilterSubList(const FilterSubList&) = delete; + FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters} + { rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; } + ~FilterSubList(); + + FilterSubList& operator=(const FilterSubList&) = delete; + FilterSubList& operator=(FilterSubList&& rhs) noexcept + { std::swap(FreeMask, rhs.FreeMask); std::swap(Filters, rhs.Filters); return *this; } +}; + #endif diff --git a/al/source.h b/al/source.h index 1a93d927..84fd7664 100644 --- a/al/source.h +++ b/al/source.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -1042,4 +1043,19 @@ private: void UpdateAllSourceProps(ALCcontext *context); +struct SourceSubList { + uint64_t FreeMask{~0_u64}; + gsl::owner*> Sources{nullptr}; + + SourceSubList() noexcept = default; + SourceSubList(const SourceSubList&) = delete; + SourceSubList(SourceSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Sources{rhs.Sources} + { rhs.FreeMask = ~0_u64; rhs.Sources = nullptr; } + ~SourceSubList(); + + SourceSubList& operator=(const SourceSubList&) = delete; + SourceSubList& operator=(SourceSubList&& rhs) noexcept + { std::swap(FreeMask, rhs.FreeMask); std::swap(Sources, rhs.Sources); return *this; } +}; + #endif diff --git a/alc/context.h b/alc/context.h index d033c08e..86ef140d 100644 --- a/alc/context.h +++ b/alc/context.h @@ -37,6 +37,8 @@ struct ALeffect; struct ALeffectslot; struct ALsource; struct DebugGroup; +struct EffectSlotSubList; +struct SourceSubList; enum class DebugSource : uint8_t; enum class DebugType : uint8_t; @@ -69,37 +71,6 @@ struct DebugLogEntry { }; -struct SourceSubList { - uint64_t FreeMask{~0_u64}; - gsl::owner*> Sources{nullptr}; - - SourceSubList() noexcept = default; - SourceSubList(const SourceSubList&) = delete; - SourceSubList(SourceSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Sources{rhs.Sources} - { rhs.FreeMask = ~0_u64; rhs.Sources = nullptr; } - ~SourceSubList(); - - SourceSubList& operator=(const SourceSubList&) = delete; - SourceSubList& operator=(SourceSubList&& rhs) noexcept - { std::swap(FreeMask, rhs.FreeMask); std::swap(Sources, rhs.Sources); return *this; } -}; - -struct EffectSlotSubList { - uint64_t FreeMask{~0_u64}; - gsl::owner*> EffectSlots{nullptr}; - - EffectSlotSubList() noexcept = default; - EffectSlotSubList(const EffectSlotSubList&) = delete; - EffectSlotSubList(EffectSlotSubList&& rhs) noexcept - : FreeMask{rhs.FreeMask}, EffectSlots{rhs.EffectSlots} - { rhs.FreeMask = ~0_u64; rhs.EffectSlots = nullptr; } - ~EffectSlotSubList(); - - EffectSlotSubList& operator=(const EffectSlotSubList&) = delete; - EffectSlotSubList& operator=(EffectSlotSubList&& rhs) noexcept - { std::swap(FreeMask, rhs.FreeMask); std::swap(EffectSlots, rhs.EffectSlots); return *this; } -}; - struct ALCcontext : public al::intrusive_ref, ContextBase { const al::intrusive_ptr mALDevice; diff --git a/alc/device.cpp b/alc/device.cpp index f13e6071..fc145579 100644 --- a/alc/device.cpp +++ b/alc/device.cpp @@ -6,6 +6,9 @@ #include #include +#include "al/buffer.h" +#include "al/effect.h" +#include "al/filter.h" #include "albit.h" #include "alconfig.h" #include "backends/base.h" diff --git a/alc/device.h b/alc/device.h index fe9dff67..dd9335dc 100644 --- a/alc/device.h +++ b/alc/device.h @@ -30,56 +30,13 @@ struct ALbuffer; struct ALeffect; struct ALfilter; struct BackendBase; +struct BufferSubList; +struct EffectSubList; +struct FilterSubList; using uint = unsigned int; -struct BufferSubList { - uint64_t FreeMask{~0_u64}; - gsl::owner*> Buffers{nullptr}; - - BufferSubList() noexcept = default; - BufferSubList(const BufferSubList&) = delete; - BufferSubList(BufferSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Buffers{rhs.Buffers} - { rhs.FreeMask = ~0_u64; rhs.Buffers = nullptr; } - ~BufferSubList(); - - BufferSubList& operator=(const BufferSubList&) = delete; - BufferSubList& operator=(BufferSubList&& rhs) noexcept - { std::swap(FreeMask, rhs.FreeMask); std::swap(Buffers, rhs.Buffers); return *this; } -}; - -struct EffectSubList { - uint64_t FreeMask{~0_u64}; - gsl::owner*> Effects{nullptr}; /* 64 */ - - EffectSubList() noexcept = default; - EffectSubList(const EffectSubList&) = delete; - EffectSubList(EffectSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Effects{rhs.Effects} - { rhs.FreeMask = ~0_u64; rhs.Effects = nullptr; } - ~EffectSubList(); - - EffectSubList& operator=(const EffectSubList&) = delete; - EffectSubList& operator=(EffectSubList&& rhs) noexcept - { std::swap(FreeMask, rhs.FreeMask); std::swap(Effects, rhs.Effects); return *this; } -}; - -struct FilterSubList { - uint64_t FreeMask{~0_u64}; - gsl::owner*> Filters{nullptr}; - - FilterSubList() noexcept = default; - FilterSubList(const FilterSubList&) = delete; - FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters} - { rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; } - ~FilterSubList(); - - FilterSubList& operator=(const FilterSubList&) = delete; - FilterSubList& operator=(FilterSubList&& rhs) noexcept - { std::swap(FreeMask, rhs.FreeMask); std::swap(Filters, rhs.Filters); return *this; } -}; - - struct ALCdevice : public al::intrusive_ref, DeviceBase { /* This lock protects the device state (format, update size, etc) from * being from being changed in multiple threads, or being accessed while -- cgit v1.2.3