From 7cda37a67c8f147536c53f0073df9a9e61d40587 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 4 May 2023 08:03:40 -0700 Subject: Replace al::optional with std::optional --- alc/panning.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'alc/panning.cpp') diff --git a/alc/panning.cpp b/alc/panning.cpp index d118f99c..a3d639fc 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "AL/al.h" @@ -45,7 +46,6 @@ #include "almalloc.h" #include "alnumbers.h" #include "alnumeric.h" -#include "aloptional.h" #include "alspan.h" #include "alstring.h" #include "alu.h" @@ -933,7 +933,7 @@ void InitUhjPanning(ALCdevice *device) } // namespace -void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional stereomode) +void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional stereomode) { /* Hold the HRTF the device last used, in case it's used again. */ HrtfStorePtr old_hrtf{std::move(device->mHrtf)}; -- cgit v1.2.3 From c14ca5f3aa6da354440a60656062f6bc68d6fca6 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 4 May 2023 18:42:27 -0700 Subject: Remove custom stuff for standard --- alc/alc.cpp | 2 +- alc/backends/jack.cpp | 2 +- alc/backends/pipewire.cpp | 4 +-- alc/backends/wasapi.cpp | 4 +-- alc/panning.cpp | 10 +++---- common/alcomplex.cpp | 2 +- common/alnumbers.h | 16 +++++------ common/alspan.h | 69 +++++++++++++++-------------------------------- core/ambdec.cpp | 2 +- core/voice.cpp | 2 +- 10 files changed, 44 insertions(+), 69 deletions(-) (limited to 'alc/panning.cpp') diff --git a/alc/alc.cpp b/alc/alc.cpp index d226b39d..290cc3d1 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1093,7 +1093,7 @@ void alc_initconfig(void) ALSOFT_GIT_BRANCH); { std::string names; - if(al::size(BackendList) < 1) + if(std::size(BackendList) < 1) names = "(none)"; else { diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp index dbc2b038..7e1e8fc7 100644 --- a/alc/backends/jack.cpp +++ b/alc/backends/jack.cpp @@ -587,7 +587,7 @@ void JackPlayback::start() throw al::backend_exception{al::backend_error::DeviceError, "No playback ports found"}; } - for(size_t i{0};i < al::size(mPort) && mPort[i];++i) + for(size_t i{0};i < std::size(mPort) && mPort[i];++i) { if(!pnames[i]) { diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index 9fccf58d..dc52a44d 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -800,7 +800,7 @@ void DeviceNode::parseChannelCount(const spa_pod *value) noexcept constexpr char MonitorPrefix[]{"Monitor of "}; -constexpr auto MonitorPrefixLen = al::size(MonitorPrefix) - 1; +constexpr auto MonitorPrefixLen = std::size(MonitorPrefix) - 1; constexpr char AudioSinkClass[]{"Audio/Sink"}; constexpr char AudioSourceClass[]{"Audio/Source"}; constexpr char AudioSourceVirtualClass[]{"Audio/Source/Virtual"}; @@ -837,7 +837,7 @@ struct NodeProxy { * format, which is what we're interested in). */ uint32_t fmtids[]{SPA_PARAM_EnumFormat}; - ppw_node_subscribe_params(mNode.get(), al::data(fmtids), al::size(fmtids)); + ppw_node_subscribe_params(mNode.get(), std::data(fmtids), std::size(fmtids)); } ~NodeProxy() { spa_hook_remove(&mListener); } diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 16576733..97f0a291 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -125,7 +125,7 @@ constexpr DWORD X71Mask{MaskFromTopBits(X7DOT1)}; constexpr DWORD X714Mask{MaskFromTopBits(X7DOT1DOT4)}; constexpr char DevNameHead[] = "OpenAL Soft on "; -constexpr size_t DevNameHeadLen{al::size(DevNameHead) - 1}; +constexpr size_t DevNameHeadLen{std::size(DevNameHead) - 1}; /* Scales the given reftime value, rounding the result. */ @@ -142,7 +142,7 @@ class GuidPrinter { public: GuidPrinter(const GUID &guid) { - std::snprintf(mMsg, al::size(mMsg), "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + std::snprintf(mMsg, std::size(mMsg), "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", DWORD{guid.Data1}, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); } diff --git a/alc/panning.cpp b/alc/panning.cpp index a3d639fc..60ce7ca4 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -346,10 +346,10 @@ DecoderView MakeDecoderView(ALCdevice *device, const AmbDecConf *conf, } std::copy_n(std::begin(conf->HFOrderGain), - std::min(al::size(conf->HFOrderGain), al::size(decoder.mOrderGain)), + std::min(std::size(conf->HFOrderGain), std::size(decoder.mOrderGain)), std::begin(decoder.mOrderGain)); std::copy_n(std::begin(conf->LFOrderGain), - std::min(al::size(conf->LFOrderGain), al::size(decoder.mOrderGainLF)), + std::min(std::size(conf->LFOrderGain), std::size(decoder.mOrderGainLF)), std::begin(decoder.mOrderGainLF)); const auto num_coeffs = decoder.mIs3D ? AmbiChannelsFromOrder(decoder.mOrder) @@ -818,9 +818,9 @@ void InitHrtfPanning(ALCdevice *device) /*RMS 8.340921354e-01f, 7.182670250e-01f, 5.107426573e-01f, 2.541870634e-01f*/ }; - static_assert(al::size(AmbiPoints1O) == al::size(AmbiMatrix1O), "First-Order Ambisonic HRTF mismatch"); - static_assert(al::size(AmbiPoints2O) == al::size(AmbiMatrix2O), "Second-Order Ambisonic HRTF mismatch"); - static_assert(al::size(AmbiPoints3O) == al::size(AmbiMatrix3O), "Third-Order Ambisonic HRTF mismatch"); + static_assert(std::size(AmbiPoints1O) == std::size(AmbiMatrix1O), "First-Order Ambisonic HRTF mismatch"); + static_assert(std::size(AmbiPoints2O) == std::size(AmbiMatrix2O), "Second-Order Ambisonic HRTF mismatch"); + static_assert(std::size(AmbiPoints3O) == std::size(AmbiMatrix3O), "Third-Order Ambisonic HRTF mismatch"); /* A 700hz crossover frequency provides tighter sound imaging at the sweet * spot with ambisonic decoding, as the distance between the ears is closer diff --git a/common/alcomplex.cpp b/common/alcomplex.cpp index 4420a1bb..a1ca822d 100644 --- a/common/alcomplex.cpp +++ b/common/alcomplex.cpp @@ -58,7 +58,7 @@ struct BitReverser { ++ret_i; } } - assert(ret_i == al::size(mData)); + assert(ret_i == std::size(mData)); } }; diff --git a/common/alnumbers.h b/common/alnumbers.h index 37a55410..800b1f2a 100644 --- a/common/alnumbers.h +++ b/common/alnumbers.h @@ -13,21 +13,21 @@ namespace detail_ { } // detail_ template -static constexpr auto pi_v = detail_::as_fp(3.141592653589793238462643383279502884L); +constexpr auto pi_v = detail_::as_fp(3.141592653589793238462643383279502884L); template -static constexpr auto inv_pi_v = detail_::as_fp(0.318309886183790671537767526745028724L); +constexpr auto inv_pi_v = detail_::as_fp(0.318309886183790671537767526745028724L); template -static constexpr auto sqrt2_v = detail_::as_fp(1.414213562373095048801688724209698079L); +constexpr auto sqrt2_v = detail_::as_fp(1.414213562373095048801688724209698079L); template -static constexpr auto sqrt3_v = detail_::as_fp(1.732050807568877293527446341505872367L); +constexpr auto sqrt3_v = detail_::as_fp(1.732050807568877293527446341505872367L); -static constexpr auto pi = pi_v; -static constexpr auto inv_pi = inv_pi_v; -static constexpr auto sqrt2 = sqrt2_v; -static constexpr auto sqrt3 = sqrt3_v; +constexpr auto pi = pi_v; +constexpr auto inv_pi = inv_pi_v; +constexpr auto sqrt2 = sqrt2_v; +constexpr auto sqrt3 = sqrt3_v; } // namespace numbers diff --git a/common/alspan.h b/common/alspan.h index 1d6cdfe5..42b3e057 100644 --- a/common/alspan.h +++ b/common/alspan.h @@ -12,41 +12,12 @@ namespace al { -template -constexpr auto size(const T &cont) noexcept(noexcept(cont.size())) -> decltype(cont.size()) -{ return cont.size(); } - -template -constexpr size_t size(const T (&)[N]) noexcept -{ return N; } - - -template -constexpr auto data(T &cont) noexcept(noexcept(cont.data())) -> decltype(cont.data()) -{ return cont.data(); } - -template -constexpr auto data(const T &cont) noexcept(noexcept(cont.data())) -> decltype(cont.data()) -{ return cont.data(); } - -template -constexpr T* data(T (&arr)[N]) noexcept -{ return arr; } - -template -constexpr const T* data(std::initializer_list list) noexcept -{ return list.begin(); } - - constexpr size_t dynamic_extent{static_cast(-1)}; template class span; namespace detail_ { - template - using void_t = void; - template struct is_span_ : std::false_type { }; template @@ -65,7 +36,7 @@ namespace detail_ { constexpr bool has_size_and_data = false; template constexpr bool has_size_and_data())), decltype(al::data(std::declval()))>> + std::void_t())),decltype(std::data(std::declval()))>> = true; template @@ -74,7 +45,7 @@ namespace detail_ { template constexpr bool is_valid_container = !is_span_v && !is_std_array_v && !std::is_array::value && has_size_and_data - && is_array_compatible()))>,T>; + && is_array_compatible()))>,T>; } // namespace detail_ #define REQUIRES(...) std::enable_if_t<(__VA_ARGS__),bool> = true @@ -107,25 +78,27 @@ public: constexpr explicit span(U first, V) : mData{to_address(first)} { } constexpr span(type_identity_t (&arr)[E]) noexcept - : span{al::data(arr), al::size(arr)} + : span{std::data(arr), std::size(arr)} + { } + constexpr span(std::array &arr) noexcept + : span{std::data(arr), std::size(arr)} { } - constexpr span(std::array &arr) noexcept : span{al::data(arr), al::size(arr)} { } template::value)> constexpr span(const std::array &arr) noexcept - : span{al::data(arr), al::size(arr)} + : span{std::data(arr), std::size(arr)} { } template)> - constexpr explicit span(U&& cont) : span{al::data(cont), al::size(cont)} { } + constexpr explicit span(U&& cont) : span{std::data(cont), std::size(cont)} { } template::value && detail_::is_array_compatible && N == dynamic_extent)> constexpr explicit span(const span &span_) noexcept - : span{al::data(span_), al::size(span_)} + : span{std::data(span_), std::size(span_)} { } template::value && detail_::is_array_compatible && N == extent)> - constexpr span(const span &span_) noexcept : span{al::data(span_), al::size(span_)} { } + constexpr span(const span &span_) noexcept : span{std::data(span_), std::size(span_)} { } constexpr span(const span&) noexcept = default; constexpr span& operator=(const span &rhs) noexcept = default; @@ -224,21 +197,23 @@ public: template constexpr span(type_identity_t (&arr)[N]) noexcept - : span{al::data(arr), al::size(arr)} + : span{std::data(arr), std::size(arr)} { } template - constexpr span(std::array &arr) noexcept : span{al::data(arr), al::size(arr)} { } + constexpr span(std::array &arr) noexcept + : span{std::data(arr), std::size(arr)} + { } template::value)> constexpr span(const std::array &arr) noexcept - : span{al::data(arr), al::size(arr)} + : span{std::data(arr), std::size(arr)} { } template)> - constexpr span(U&& cont) : span{al::data(cont), al::size(cont)} { } + constexpr span(U&& cont) : span{std::data(cont), std::size(cont)} { } template::value || extent != N) && detail_::is_array_compatible)> - constexpr span(const span &span_) noexcept : span{al::data(span_), al::size(span_)} { } + constexpr span(const span &span_) noexcept : span{std::data(span_), std::size(span_)} { } constexpr span(const span&) noexcept = default; constexpr span& operator=(const span &rhs) noexcept = default; @@ -330,19 +305,19 @@ constexpr auto as_span(T ptr, U count_or_end) return span{ptr, count_or_end}; } template -constexpr auto as_span(T (&arr)[N]) noexcept { return span{al::data(arr), al::size(arr)}; } +constexpr auto as_span(T (&arr)[N]) noexcept { return span{std::data(arr), std::size(arr)}; } template constexpr auto as_span(std::array &arr) noexcept -{ return span{al::data(arr), al::size(arr)}; } +{ return span{std::data(arr), std::size(arr)}; } template constexpr auto as_span(const std::array &arr) noexcept -{ return span,N>{al::data(arr), al::size(arr)}; } +{ return span,N>{std::data(arr), std::size(arr)}; } template && !detail_::is_std_array_v && !std::is_array::value && detail_::has_size_and_data)> constexpr auto as_span(U&& cont) { - using value_type = std::remove_pointer_t()))>; - return span{al::data(cont), al::size(cont)}; + using value_type = std::remove_pointer_t()))>; + return span{std::data(cont), std::size(cont)}; } template constexpr auto as_span(span span_) noexcept { return span_; } diff --git a/core/ambdec.cpp b/core/ambdec.cpp index a056e63f..f98e1098 100644 --- a/core/ambdec.cpp +++ b/core/ambdec.cpp @@ -139,7 +139,7 @@ std::optional AmbDecConf::load(const char *fname) noexcept { --toread; istr >> value; - if(curgain < al::size(gains)) + if(curgain < std::size(gains)) gains[curgain++] = value; } } diff --git a/core/voice.cpp b/core/voice.cpp index cbf84c2a..db6b6d27 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -288,7 +288,7 @@ inline void LoadSamples(float *RESTRICT dstSamples, const std::byte *sr /* NOTE: This could probably be optimized better. */ size_t wrote{0}; do { - static constexpr int MaxStepIndex{static_cast(al::size(IMAStep_size)) - 1}; + static constexpr int MaxStepIndex{static_cast(std::size(IMAStep_size)) - 1}; /* Each IMA4 block starts with a signed 16-bit sample, and a signed * 16-bit table index. The table index needs to be clamped. */ -- cgit v1.2.3 From e7ea579ca5f3c0da6cfe80ec9a7295bca60198aa Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 12 May 2023 18:02:12 -0700 Subject: Avoid using al::vector unnecessarily --- al/auxeffectslot.cpp | 8 +++---- al/buffer.cpp | 5 +++-- al/effect.cpp | 4 ++-- al/error.cpp | 4 ++-- al/filter.cpp | 4 ++-- al/source.cpp | 13 ++++++------ alc/alc.cpp | 12 +++++------ alc/backends/alsa.cpp | 16 +++++++------- alc/backends/coreaudio.cpp | 4 ++-- alc/backends/dsound.cpp | 9 ++++---- alc/backends/jack.cpp | 5 +++-- alc/backends/oss.cpp | 14 ++++++------ alc/backends/pulseaudio.cpp | 6 +++--- alc/backends/solaris.cpp | 4 ++-- alc/backends/wasapi.cpp | 18 ++++++++-------- alc/backends/wave.cpp | 4 ++-- alc/backends/winmm.cpp | 2 +- alc/context.h | 6 +++--- alc/device.h | 10 ++++----- alc/effects/chorus.cpp | 4 ++-- alc/effects/echo.cpp | 6 +++--- alc/panning.cpp | 3 ++- core/bformatdec.h | 4 ++-- core/hrtf.cpp | 52 ++++++++++++++++++++++----------------------- core/hrtf.h | 4 ++-- core/logging.cpp | 4 ++-- 26 files changed, 115 insertions(+), 110 deletions(-) (limited to 'alc/panning.cpp') diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index c69990fe..3a3222b8 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -341,7 +341,7 @@ START_API_FUNC } else { - al::vector ids; + std::vector ids; ALsizei count{n}; ids.reserve(static_cast(count)); do { @@ -383,7 +383,7 @@ START_API_FUNC } else { - auto slots = al::vector(static_cast(n)); + auto slots = std::vector(static_cast(n)); for(size_t i{0};i < slots.size();++i) { ALeffectslot *slot{LookupEffectSlot(context.get(), effectslots[i])}; @@ -466,7 +466,7 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Playing %d effect slots", n); if(n <= 0) UNLIKELY return; - auto slots = al::vector(static_cast(n)); + auto slots = std::vector(static_cast(n)); std::lock_guard _{context->mEffectSlotLock}; for(size_t i{0};i < slots.size();++i) { @@ -520,7 +520,7 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Stopping %d effect slots", n); if(n <= 0) UNLIKELY return; - auto slots = al::vector(static_cast(n)); + auto slots = std::vector(static_cast(n)); std::lock_guard _{context->mEffectSlotLock}; for(size_t i{0};i < slots.size();++i) { diff --git a/al/buffer.cpp b/al/buffer.cpp index 1f008c8e..bfc10906 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -345,7 +346,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, */ if(newsize != ALBuf->mDataStorage.size()) { - auto newdata = al::vector(newsize, std::byte{}); + auto newdata = decltype(ALBuf->mDataStorage)(newsize, std::byte{}); if((access&AL_PRESERVE_DATA_BIT_SOFT)) { const size_t tocopy{minz(newdata.size(), ALBuf->mDataStorage.size())}; @@ -663,7 +664,7 @@ START_API_FUNC /* Store the allocated buffer IDs in a separate local list, to avoid * modifying the user storage in case of failure. */ - al::vector ids; + std::vector ids; ids.reserve(static_cast(n)); do { ALbuffer *buffer{AllocBuffer(device)}; diff --git a/al/effect.cpp b/al/effect.cpp index 3d91139a..3ca7c37e 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -49,7 +50,6 @@ #include "core/except.h" #include "core/logging.h" #include "opthelpers.h" -#include "vector.h" #ifdef ALSOFT_EAX #include @@ -259,7 +259,7 @@ START_API_FUNC /* Store the allocated buffer IDs in a separate local list, to avoid * modifying the user storage in case of failure. */ - al::vector ids; + std::vector ids; ids.reserve(static_cast(n)); do { ALeffect *effect{AllocEffect(device)}; diff --git a/al/error.cpp b/al/error.cpp index 39fd9f0a..b0607d66 100644 --- a/al/error.cpp +++ b/al/error.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -41,14 +42,13 @@ #include "core/except.h" #include "core/logging.h" #include "opthelpers.h" -#include "vector.h" bool TrapALError{false}; void ALCcontext::setError(ALenum errorCode, const char *msg, ...) { - auto message = al::vector(256); + auto message = std::vector(256); va_list args, args2; va_start(args, msg); diff --git a/al/filter.cpp b/al/filter.cpp index 0fd8eaa8..11d71179 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -43,7 +44,6 @@ #include "alnumeric.h" #include "core/except.h" #include "opthelpers.h" -#include "vector.h" namespace { @@ -430,7 +430,7 @@ START_API_FUNC /* Store the allocated buffer IDs in a separate local list, to avoid * modifying the user storage in case of failure. */ - al::vector ids; + std::vector ids; ids.reserve(static_cast(n)); do { ALfilter *filter{AllocFilter(device)}; diff --git a/al/source.cpp b/al/source.cpp index efe65332..1bfd5a94 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -2659,7 +2660,7 @@ START_API_FUNC } else { - al::vector ids; + std::vector ids; ids.reserve(static_cast(n)); do { ALsource *source{AllocSource(context.get())}; @@ -3223,7 +3224,7 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Playing %d sources", n); if(n <= 0) UNLIKELY return; - al::vector extra_sources; + std::vector extra_sources; std::array source_storage; al::span srchandles; if(static_cast(n) <= source_storage.size()) LIKELY @@ -3261,7 +3262,7 @@ START_API_FUNC if(start_time < 0) UNLIKELY return context->setError(AL_INVALID_VALUE, "Invalid time point %" PRId64, start_time); - al::vector extra_sources; + std::vector extra_sources; std::array source_storage; al::span srchandles; if(static_cast(n) <= source_storage.size()) LIKELY @@ -3301,7 +3302,7 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Pausing %d sources", n); if(n <= 0) UNLIKELY return; - al::vector extra_sources; + std::vector extra_sources; std::array source_storage; al::span srchandles; if(static_cast(n) <= source_storage.size()) LIKELY @@ -3377,7 +3378,7 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Stopping %d sources", n); if(n <= 0) UNLIKELY return; - al::vector extra_sources; + std::vector extra_sources; std::array source_storage; al::span srchandles; if(static_cast(n) <= source_storage.size()) LIKELY @@ -3440,7 +3441,7 @@ START_API_FUNC context->setError(AL_INVALID_VALUE, "Rewinding %d sources", n); if(n <= 0) UNLIKELY return; - al::vector extra_sources; + std::vector extra_sources; std::array source_storage; al::span srchandles; if(static_cast(n) <= source_storage.size()) LIKELY diff --git a/alc/alc.cpp b/alc/alc.cpp index 290cc3d1..9fedee0b 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -102,7 +103,6 @@ #include "opthelpers.h" #include "strutils.h" #include "threads.h" -#include "vector.h" #include "backends/base.h" #include "backends/null.h" @@ -1050,8 +1050,8 @@ using DeviceRef = al::intrusive_ptr; /************************************************ * Device lists ************************************************/ -al::vector DeviceList; -al::vector ContextList; +std::vector DeviceList; +std::vector ContextList; std::recursive_mutex ListLock; @@ -3130,7 +3130,7 @@ START_API_FUNC } if(!dev || dev->Type == DeviceType::Capture) { - auto ivals = al::vector(static_cast(size)); + auto ivals = std::vector(static_cast(size)); if(size_t got{GetIntegerv(dev.get(), pname, ivals)}) std::copy_n(ivals.begin(), got, values); return; @@ -3249,7 +3249,7 @@ START_API_FUNC break; default: - auto ivals = al::vector(static_cast(size)); + auto ivals = std::vector(static_cast(size)); if(size_t got{GetIntegerv(dev.get(), pname, ivals)}) std::copy_n(ivals.begin(), got, values); break; @@ -3676,7 +3676,7 @@ START_API_FUNC DeviceList.erase(iter); std::unique_lock statelock{dev->StateLock}; - al::vector orphanctxs; + std::vector orphanctxs; for(ContextBase *ctx : *dev->mContexts.load()) { auto ctxiter = std::lower_bound(ContextList.begin(), ContextList.end(), ctx); diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index c1690867..ce368f5e 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "albit.h" #include "alc/alconfig.h" @@ -46,7 +47,6 @@ #include "dynload.h" #include "ringbuffer.h" #include "threads.h" -#include "vector.h" #include @@ -248,8 +248,8 @@ struct DevMap { { } }; -al::vector PlaybackDevices; -al::vector CaptureDevices; +std::vector PlaybackDevices; +std::vector CaptureDevices; const char *prefix_name(snd_pcm_stream_t stream) @@ -258,9 +258,9 @@ const char *prefix_name(snd_pcm_stream_t stream) return (stream==SND_PCM_STREAM_PLAYBACK) ? "device-prefix" : "capture-prefix"; } -al::vector probe_devices(snd_pcm_stream_t stream) +std::vector probe_devices(snd_pcm_stream_t stream) { - al::vector devlist; + std::vector devlist; snd_ctl_card_info_t *info; snd_ctl_card_info_malloc(&info); @@ -439,7 +439,7 @@ struct AlsaPlayback final : public BackendBase { std::mutex mMutex; uint mFrameStep{}; - al::vector mBuffer; + std::vector mBuffer; std::atomic mKillNow{true}; std::thread mThread; @@ -880,7 +880,7 @@ struct AlsaCapture final : public BackendBase { snd_pcm_t *mPcmHandle{nullptr}; - al::vector mBuffer; + std::vector mBuffer; bool mDoCapture{false}; RingBufferPtr mRing{nullptr}; @@ -1024,7 +1024,7 @@ void AlsaCapture::stop() /* The ring buffer implicitly captures when checking availability. * Direct access needs to explicitly capture it into temp storage. */ - auto temp = al::vector( + auto temp = std::vector( static_cast(snd_pcm_frames_to_bytes(mPcmHandle, avail))); captureSamples(temp.data(), avail); mBuffer = std::move(temp); diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp index c2a79815..521f085d 100644 --- a/alc/backends/coreaudio.cpp +++ b/alc/backends/coreaudio.cpp @@ -25,13 +25,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include "alnumeric.h" #include "core/converter.h" @@ -578,7 +578,7 @@ struct CoreAudioCapture final : public BackendBase { SampleConverterPtr mConverter; - al::vector mCaptureData; + std::vector mCaptureData; RingBufferPtr mRing{nullptr}; diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp index ffcd8430..5fc8a1c7 100644 --- a/alc/backends/dsound.cpp +++ b/alc/backends/dsound.cpp @@ -46,6 +46,7 @@ #include "albit.h" #include "alnumeric.h" +#include "alspan.h" #include "comptr.h" #include "core/device.h" #include "core/helpers.h" @@ -130,10 +131,10 @@ struct DevMap { { } }; -al::vector PlaybackDevices; -al::vector CaptureDevices; +std::vector PlaybackDevices; +std::vector CaptureDevices; -bool checkName(const al::vector &list, const std::string &name) +bool checkName(const al::span list, const std::string &name) { auto match_name = [&name](const DevMap &entry) -> bool { return entry.name == name; }; @@ -145,7 +146,7 @@ BOOL CALLBACK DSoundEnumDevices(GUID *guid, const WCHAR *desc, const WCHAR*, voi if(!guid) return TRUE; - auto& devices = *static_cast*>(data); + auto& devices = *static_cast*>(data); const std::string basename{DEVNAME_HEAD + wstr_to_utf8(desc)}; int count{1}; diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp index b12edf9f..9e023e21 100644 --- a/alc/backends/jack.cpp +++ b/alc/backends/jack.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "albit.h" #include "alc/alconfig.h" @@ -168,10 +169,10 @@ struct DeviceEntry { { } }; -al::vector PlaybackList; +std::vector PlaybackList; -void EnumerateDevices(jack_client_t *client, al::vector &list) +void EnumerateDevices(jack_client_t *client, std::vector &list) { std::remove_reference_t{}.swap(list); diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp index 1fdee701..dc18c4c3 100644 --- a/alc/backends/oss.cpp +++ b/alc/backends/oss.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "alc/alconfig.h" #include "almalloc.h" @@ -47,7 +48,6 @@ #include "core/logging.h" #include "ringbuffer.h" #include "threads.h" -#include "vector.h" #include @@ -88,22 +88,22 @@ struct DevMap { std::string device_name; }; -al::vector PlaybackDevices; -al::vector CaptureDevices; +std::vector PlaybackDevices; +std::vector CaptureDevices; #ifdef ALC_OSS_COMPAT #define DSP_CAP_OUTPUT 0x00020000 #define DSP_CAP_INPUT 0x00010000 -void ALCossListPopulate(al::vector &devlist, int type) +void ALCossListPopulate(std::vector &devlist, int type) { devlist.emplace_back(DevMap{DefaultName, (type==DSP_CAP_INPUT) ? DefaultCapture : DefaultPlayback}); } #else -void ALCossListAppend(al::vector &list, al::span handle, al::span path) +void ALCossListAppend(std::vector &list, al::span handle, al::span path) { #ifdef ALC_OSS_DEVNODE_TRUC for(size_t i{0};i < path.size();++i) @@ -148,7 +148,7 @@ void ALCossListAppend(al::vector &list, al::span handle, al: TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str()); } -void ALCossListPopulate(al::vector &devlist, int type_flag) +void ALCossListPopulate(std::vector &devlist, int type_flag) { int fd{open("/dev/mixer", O_RDONLY)}; if(fd < 0) @@ -234,7 +234,7 @@ struct OSSPlayback final : public BackendBase { int mFd{-1}; - al::vector mMixData; + std::vector mMixData; std::atomic mKillNow{true}; std::thread mThread; diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index e5696817..d2883f5c 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "albit.h" #include "alc/alconfig.h" @@ -49,7 +50,6 @@ #include "dynload.h" #include "opthelpers.h" #include "strutils.h" -#include "vector.h" #include @@ -282,8 +282,8 @@ bool checkName(const al::span list, const std::string &name) return std::find_if(list.cbegin(), list.cend(), match_name) != list.cend(); } -al::vector PlaybackDevices; -al::vector CaptureDevices; +std::vector PlaybackDevices; +std::vector CaptureDevices; /* Global flags and properties */ diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp index 4eeeafac..ae87e7eb 100644 --- a/alc/backends/solaris.cpp +++ b/alc/backends/solaris.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -44,7 +45,6 @@ #include "core/helpers.h" #include "core/logging.h" #include "threads.h" -#include "vector.h" #include @@ -70,7 +70,7 @@ struct SolarisBackend final : public BackendBase { int mFd{-1}; uint mFrameStep{}; - al::vector mBuffer; + std::vector mBuffer; std::atomic mKillNow{true}; std::thread mThread; diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 97f0a291..d4ad38e2 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -59,6 +59,7 @@ #include "albit.h" #include "alc/alconfig.h" #include "alnumeric.h" +#include "alspan.h" #include "comptr.h" #include "core/converter.h" #include "core/device.h" @@ -180,15 +181,14 @@ struct DevMap { { } }; -bool checkName(const al::vector &list, const std::string &name) +bool checkName(const al::span list, const std::string &name) { - auto match_name = [&name](const DevMap &entry) -> bool - { return entry.name == name; }; + auto match_name = [&name](const DevMap &entry) -> bool { return entry.name == name; }; return std::find_if(list.cbegin(), list.cend(), match_name) != list.cend(); } -al::vector PlaybackDevices; -al::vector CaptureDevices; +std::vector PlaybackDevices; +std::vector CaptureDevices; using NameGUIDPair = std::pair; @@ -262,7 +262,7 @@ EndpointFormFactor get_device_formfactor(IMMDevice *device) } -void add_device(IMMDevice *device, const WCHAR *devid, al::vector &list) +void add_device(IMMDevice *device, const WCHAR *devid, std::vector &list) { for(auto &entry : list) { @@ -301,9 +301,9 @@ WCHAR *get_device_id(IMMDevice *device) return devid; } -void probe_devices(IMMDeviceEnumerator *devenum, EDataFlow flowdir, al::vector &list) +void probe_devices(IMMDeviceEnumerator *devenum, EDataFlow flowdir, std::vector &list) { - al::vector{}.swap(list); + std::vector{}.swap(list); ComPtr coll; HRESULT hr{devenum->EnumAudioEndpoints(flowdir, DEVICE_STATE_ACTIVE, al::out_ptr(coll))}; @@ -1355,7 +1355,7 @@ FORCE_ALIGN int WasapiCapture::recordProc() althrd_setname(RECORD_THREAD_NAME); - al::vector samples; + std::vector samples; while(!mKillNow.load(std::memory_order_relaxed)) { UINT32 avail; diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp index f8302f1e..1ee2fe51 100644 --- a/alc/backends/wave.cpp +++ b/alc/backends/wave.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "albit.h" #include "alc/alconfig.h" @@ -43,7 +44,6 @@ #include "opthelpers.h" #include "strutils.h" #include "threads.h" -#include "vector.h" namespace { @@ -104,7 +104,7 @@ struct WaveBackend final : public BackendBase { FILE *mFile{nullptr}; long mDataStart{-1}; - al::vector mBuffer; + std::vector mBuffer; std::atomic mKillNow{true}; std::thread mThread; diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp index edb875a0..0345fe10 100644 --- a/alc/backends/winmm.cpp +++ b/alc/backends/winmm.cpp @@ -58,7 +58,7 @@ namespace { std::vector PlaybackDevices; std::vector CaptureDevices; -bool checkName(const al::vector &list, const std::string &name) +bool checkName(const std::vector &list, const std::string &name) { return std::find(list.cbegin(), list.cend(), name) != list.cend(); } void ProbePlaybackDevices(void) diff --git a/alc/context.h b/alc/context.h index acbb3788..779be113 100644 --- a/alc/context.h +++ b/alc/context.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -21,7 +22,6 @@ #include "core/context.h" #include "inprogext.h" #include "intrusive_ptr.h" -#include "vector.h" #ifdef ALSOFT_EAX #include "al/eax/call.h" @@ -132,11 +132,11 @@ struct ALCcontext : public al::intrusive_ref, ContextBase { ALlistener mListener{}; - al::vector mSourceList; + std::vector mSourceList; ALuint mNumSources{0}; std::mutex mSourceLock; - al::vector mEffectSlotList; + std::vector mEffectSlotList; ALuint mNumEffectSlots{0u}; std::mutex mEffectSlotLock; diff --git a/alc/device.h b/alc/device.h index d5e82ce3..1274e287 100644 --- a/alc/device.h +++ b/alc/device.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "AL/alc.h" #include "AL/alext.h" @@ -18,7 +19,6 @@ #include "core/device.h" #include "inprogext.h" #include "intrusive_ptr.h" -#include "vector.h" #ifdef ALSOFT_EAX #include "al/eax/x_ram.h" @@ -95,7 +95,7 @@ struct ALCdevice : public al::intrusive_ref, DeviceBase { uint AuxiliaryEffectSlotMax{}; std::string mHrtfName; - al::vector mHrtfList; + std::vector mHrtfList; ALCenum mHrtfStatus{ALC_FALSE}; enum class OutputMode1 : ALCenum { @@ -118,15 +118,15 @@ struct ALCdevice : public al::intrusive_ref, DeviceBase { // Map of Buffers for this device std::mutex BufferLock; - al::vector BufferList; + std::vector BufferList; // Map of Effects for this device std::mutex EffectLock; - al::vector EffectList; + std::vector EffectList; // Map of Filters for this device std::mutex FilterLock; - al::vector FilterList; + std::vector FilterList; #ifdef ALSOFT_EAX ALuint eax_x_ram_free_size{eax_x_ram_max_size}; diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 10ccf9f6..7c281aa5 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "alc/effects/base.h" #include "almalloc.h" @@ -41,7 +42,6 @@ #include "core/resampler_limits.h" #include "intrusive_ptr.h" #include "opthelpers.h" -#include "vector.h" namespace { @@ -49,7 +49,7 @@ namespace { using uint = unsigned int; struct ChorusState final : public EffectState { - al::vector mDelayBuffer; + std::vector mDelayBuffer; uint mOffset{0}; uint mLfoOffset{0}; diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index a69529dc..7824c246 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "alc/effects/base.h" #include "almalloc.h" @@ -39,7 +40,6 @@ #include "core/mixer.h" #include "intrusive_ptr.h" #include "opthelpers.h" -#include "vector.h" namespace { @@ -49,7 +49,7 @@ using uint = unsigned int; constexpr float LowpassFreqRef{5000.0f}; struct EchoState final : public EffectState { - al::vector mSampleBuffer; + std::vector mSampleBuffer; // The echo is two tap. The delay is the number of samples from before the // current offset @@ -87,7 +87,7 @@ void EchoState::deviceUpdate(const DeviceBase *Device, const BufferStorage*) const uint maxlen{NextPowerOf2(float2uint(EchoMaxDelay*frequency + 0.5f) + float2uint(EchoMaxLRDelay*frequency + 0.5f))}; if(maxlen != mSampleBuffer.size()) - al::vector(maxlen).swap(mSampleBuffer); + decltype(mSampleBuffer)(maxlen).swap(mSampleBuffer); std::fill(mSampleBuffer.begin(), mSampleBuffer.end(), 0.0f); for(auto &e : mGains) diff --git a/alc/panning.cpp b/alc/panning.cpp index 60ce7ca4..6fc955ee 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "AL/al.h" #include "AL/alc.h" @@ -628,7 +629,7 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= const size_t ambicount{decoder.mIs3D ? AmbiChannelsFromOrder(decoder.mOrder) : Ambi2DChannelsFromOrder(decoder.mOrder)}; const bool dual_band{hqdec && !decoder.mCoeffsLF.empty()}; - al::vector chancoeffs, chancoeffslf; + std::vector chancoeffs, chancoeffslf; for(size_t i{0u};i < decoder.mChannels.size();++i) { const uint idx{device->channelIdxByName(decoder.mChannels[i])}; diff --git a/core/bformatdec.h b/core/bformatdec.h index 7a27a5a4..42024bd9 100644 --- a/core/bformatdec.h +++ b/core/bformatdec.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "almalloc.h" #include "alspan.h" @@ -11,7 +12,6 @@ #include "bufferline.h" #include "devformat.h" #include "filters/splitter.h" -#include "vector.h" struct FrontStablizer; @@ -43,7 +43,7 @@ class BFormatDec { * only be used in a standard layout struct, and a std::unique_ptr member * (mStablizer) causes GCC and Clang to warn it's not. */ - al::vector mChannelDec; + std::vector mChannelDec; public: BFormatDec(const size_t inchans, const al::span coeffs, diff --git a/core/hrtf.cpp b/core/hrtf.cpp index 607e3d3d..7d11ee19 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "albit.h" #include "alfstream.h" @@ -34,7 +35,6 @@ #include "mixer/hrtfdefs.h" #include "opthelpers.h" #include "polyphase_resampler.h" -#include "vector.h" namespace { @@ -98,10 +98,10 @@ constexpr char magicMarker03[8]{'M','i','n','P','H','R','0','3'}; constexpr auto PassthruCoeff = static_cast(1.0/al::numbers::sqrt2); std::mutex LoadedHrtfLock; -al::vector LoadedHrtfs; +std::vector LoadedHrtfs; std::mutex EnumeratedHrtfLock; -al::vector EnumeratedHrtfs; +std::vector EnumeratedHrtfs; class databuf final : public std::streambuf { @@ -295,7 +295,7 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const uint irSize, const bool } uint min_delay{HrtfHistoryLength*HrirDelayFracOne}, max_delay{0}; - al::vector impres; impres.reserve(AmbiPoints.size()); + std::vector impres; impres.reserve(AmbiPoints.size()); auto calc_res = [Hrtf,&max_delay,&min_delay](const AngularPoint &pt) -> ImpulseResponse { auto &field = Hrtf->mFields[0]; @@ -331,7 +331,7 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const uint irSize, const bool TRACE("Min delay: %.2f, max delay: %.2f, FIR length: %u\n", min_delay/double{HrirDelayFracOne}, max_delay/double{HrirDelayFracOne}, irSize); - auto tmpres = al::vector>(mChannels.size()); + auto tmpres = std::vector>(mChannels.size()); max_delay = 0; for(size_t c{0u};c < AmbiPoints.size();++c) { @@ -529,7 +529,7 @@ std::unique_ptr LoadHrtf00(std::istream &data, const char *filename) return nullptr; } - auto elevs = al::vector(evCount); + auto elevs = std::vector(evCount); for(auto &elev : elevs) elev.irOffset = readle(data); if(!data || data.eof()) @@ -571,8 +571,8 @@ std::unique_ptr LoadHrtf00(std::istream &data, const char *filename) return nullptr; } - auto coeffs = al::vector(irCount, HrirArray{}); - auto delays = al::vector(irCount); + auto coeffs = std::vector(irCount, HrirArray{}); + auto delays = std::vector(irCount); for(auto &hrir : coeffs) { for(auto &val : al::span{hrir.data(), irSize}) @@ -626,7 +626,7 @@ std::unique_ptr LoadHrtf01(std::istream &data, const char *filename) return nullptr; } - auto elevs = al::vector(evCount); + auto elevs = std::vector(evCount); for(auto &elev : elevs) elev.azCount = readle(data); if(!data || data.eof()) @@ -649,8 +649,8 @@ std::unique_ptr LoadHrtf01(std::istream &data, const char *filename) elevs[i].irOffset = static_cast(elevs[i-1].irOffset + elevs[i-1].azCount); const ushort irCount{static_cast(elevs.back().irOffset + elevs.back().azCount)}; - auto coeffs = al::vector(irCount, HrirArray{}); - auto delays = al::vector(irCount); + auto coeffs = std::vector(irCount, HrirArray{}); + auto delays = std::vector(irCount); for(auto &hrir : coeffs) { for(auto &val : al::span{hrir.data(), irSize}) @@ -722,8 +722,8 @@ std::unique_ptr LoadHrtf02(std::istream &data, const char *filename) return nullptr; } - auto fields = al::vector(fdCount); - auto elevs = al::vector{}; + auto fields = std::vector(fdCount); + auto elevs = std::vector{}; for(size_t f{0};f < fdCount;f++) { const ushort distance{readle(data)}; @@ -787,8 +787,8 @@ std::unique_ptr LoadHrtf02(std::istream &data, const char *filename) }); const auto irTotal = static_cast(elevs.back().azCount + elevs.back().irOffset); - auto coeffs = al::vector(irTotal, HrirArray{}); - auto delays = al::vector(irTotal); + auto coeffs = std::vector(irTotal, HrirArray{}); + auto delays = std::vector(irTotal); if(channelType == ChanType_LeftOnly) { if(sampleType == SampleType_S16) @@ -881,10 +881,10 @@ std::unique_ptr LoadHrtf02(std::istream &data, const char *filename) if(fdCount > 1) { - auto fields_ = al::vector(fields.size()); - auto elevs_ = al::vector(elevs.size()); - auto coeffs_ = al::vector(coeffs.size()); - auto delays_ = al::vector(delays.size()); + auto fields_ = std::vector(fields.size()); + auto elevs_ = std::vector(elevs.size()); + auto coeffs_ = std::vector(coeffs.size()); + auto delays_ = std::vector(delays.size()); /* Simple reverse for the per-field elements. */ std::reverse_copy(fields.cbegin(), fields.cend(), fields_.begin()); @@ -983,8 +983,8 @@ std::unique_ptr LoadHrtf03(std::istream &data, const char *filename) return nullptr; } - auto fields = al::vector(fdCount); - auto elevs = al::vector{}; + auto fields = std::vector(fdCount); + auto elevs = std::vector{}; for(size_t f{0};f < fdCount;f++) { const ushort distance{readle(data)}; @@ -1048,8 +1048,8 @@ std::unique_ptr LoadHrtf03(std::istream &data, const char *filename) }); const auto irTotal = static_cast(elevs.back().azCount + elevs.back().irOffset); - auto coeffs = al::vector(irTotal, HrirArray{}); - auto delays = al::vector(irTotal); + auto coeffs = std::vector(irTotal, HrirArray{}); + auto delays = std::vector(irTotal); if(channelType == ChanType_LeftOnly) { for(auto &hrir : coeffs) @@ -1221,7 +1221,7 @@ al::span GetResource(int name) } // namespace -al::vector EnumerateHrtf(std::optional pathopt) +std::vector EnumerateHrtf(std::optional pathopt) { std::lock_guard _{EnumeratedHrtfLock}; EnumeratedHrtfs.clear(); @@ -1270,7 +1270,7 @@ al::vector EnumerateHrtf(std::optional pathopt) AddBuiltInEntry("Built-In HRTF", IDR_DEFAULT_HRTF_MHR); } - al::vector list; + std::vector list; list.reserve(EnumeratedHrtfs.size()); for(auto &entry : EnumeratedHrtfs) list.emplace_back(entry.mDispName); @@ -1394,7 +1394,7 @@ HrtfStorePtr GetLoadedHrtf(const std::string &name, const uint devrate) /* Scale the delays for the new sample rate. */ float max_delay{0.0f}; - auto new_delays = al::vector(irCount); + auto new_delays = std::vector(irCount); const float rate_scale{static_cast(devrate)/static_cast(hrtf->mSampleRate)}; for(size_t i{0};i < irCount;++i) { diff --git a/core/hrtf.h b/core/hrtf.h index 7215711b..5e6e09a8 100644 --- a/core/hrtf.h +++ b/core/hrtf.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "almalloc.h" #include "alspan.h" @@ -14,7 +15,6 @@ #include "bufferline.h" #include "mixer/hrtfdefs.h" #include "intrusive_ptr.h" -#include "vector.h" struct HrtfStore { @@ -83,7 +83,7 @@ struct DirectHrtfState { }; -al::vector EnumerateHrtf(std::optional pathopt); +std::vector EnumerateHrtf(std::optional pathopt); HrtfStorePtr GetLoadedHrtf(const std::string &name, const uint devrate); #endif /* CORE_HRTF_H */ diff --git a/core/logging.cpp b/core/logging.cpp index 8e0116ea..34385cf4 100644 --- a/core/logging.cpp +++ b/core/logging.cpp @@ -6,10 +6,10 @@ #include #include #include +#include #include "alspan.h" #include "strutils.h" -#include "vector.h" #if defined(_WIN32) @@ -34,7 +34,7 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...) case LogLevel::Trace: prefix = al::span{"[ALSOFT] (II) "}.first<14>(); break; } - al::vector dynmsg; + std::vector dynmsg; std::array stcmsg{}; char *str{stcmsg.data()}; -- cgit v1.2.3 From ec8064d1001daf968a73c8bc4f6088e905488cb7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 12 Jun 2023 13:17:00 -0700 Subject: Trace the surround decoder being used --- alc/panning.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'alc/panning.cpp') diff --git a/alc/panning.cpp b/alc/panning.cpp index 6fc955ee..46a840bd 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -979,28 +979,39 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optionalc_str()); + return false; } else if(conf.NumSpeakers > MAX_OUTPUT_CHANNELS) + { ERR("Unsupported decoder speaker count %zu (max %d)\n", conf.NumSpeakers, MAX_OUTPUT_CHANNELS); + return false; + } else if(conf.ChanMask > Ambi3OrderMask) + { ERR("Unsupported decoder channel mask 0x%04x (max 0x%x)\n", conf.ChanMask, Ambi3OrderMask); - else - { - device->mXOverFreq = clampf(conf.XOverFreq, 100.0f, 1000.0f); - - decoder_store = std::make_unique>(); - decoder = MakeDecoderView(device, &conf, *decoder_store); - for(size_t i{0};i < decoder.mChannels.size();++i) - speakerdists[i] = conf.Speakers[i].Distance; + return false; } + + TRACE("Using %s decoder: \"%s\"\n", DevFmtChannelsString(device->FmtChans), + conf.Description.c_str()); + device->mXOverFreq = clampf(conf.XOverFreq, 100.0f, 1000.0f); + + decoder_store = std::make_unique>(); + decoder = MakeDecoderView(device, &conf, *decoder_store); + for(size_t i{0};i < decoder.mChannels.size();++i) + speakerdists[i] = conf.Speakers[i].Distance; + return true; }; + bool usingCustom{false}; if(layout) { if(auto decopt = device->configValue("decoder", layout)) - load_config(decopt->c_str()); + usingCustom = load_config(decopt->c_str()); } + if(!usingCustom && device->FmtChans != DevFmtAmbi3D) + TRACE("Using built-in %s decoder\n", DevFmtChannelsString(device->FmtChans)); /* Enable the stablizer only for formats that have front-left, front- * right, and front-center outputs. -- cgit v1.2.3 From a318126ee33c47b3e017d4970b09eaf581f73004 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 14 Jun 2023 23:33:32 -0700 Subject: Use inline variables instead of functions with static variables --- alc/alu.cpp | 24 ++--- alc/effects/convolution.cpp | 24 ++--- alc/panning.cpp | 44 ++++----- core/ambidefs.h | 221 ++++++++++++++++++-------------------------- core/hrtf.cpp | 2 +- core/voice.cpp | 2 +- 6 files changed, 139 insertions(+), 178 deletions(-) (limited to 'alc/panning.cpp') diff --git a/alc/alu.cpp b/alc/alu.cpp index 0130f280..5dfb4fae 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -376,28 +376,28 @@ void UpsampleBFormatTransform( } -inline auto& GetAmbiScales(AmbiScaling scaletype) noexcept +constexpr auto GetAmbiScales(AmbiScaling scaletype) noexcept { switch(scaletype) { - case AmbiScaling::FuMa: return AmbiScale::FromFuMa(); - case AmbiScaling::SN3D: return AmbiScale::FromSN3D(); - case AmbiScaling::UHJ: return AmbiScale::FromUHJ(); + case AmbiScaling::FuMa: return al::span{AmbiScale::FromFuMa}; + case AmbiScaling::SN3D: return al::span{AmbiScale::FromSN3D}; + case AmbiScaling::UHJ: return al::span{AmbiScale::FromUHJ}; case AmbiScaling::N3D: break; } - return AmbiScale::FromN3D(); + return al::span{AmbiScale::FromN3D}; } -inline auto& GetAmbiLayout(AmbiLayout layouttype) noexcept +constexpr auto GetAmbiLayout(AmbiLayout layouttype) noexcept { - if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa(); - return AmbiIndex::FromACN(); + if(layouttype == AmbiLayout::FuMa) return al::span{AmbiIndex::FromFuMa}; + return al::span{AmbiIndex::FromACN}; } -inline auto& GetAmbi2DLayout(AmbiLayout layouttype) noexcept +constexpr auto GetAmbi2DLayout(AmbiLayout layouttype) noexcept { - if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D(); - return AmbiIndex::FromACN2D(); + if(layouttype == AmbiLayout::FuMa) return al::span{AmbiIndex::FromFuMa2D}; + return al::span{AmbiIndex::FromACN2D}; } @@ -859,7 +859,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con */ return CalcAngleCoeffs(ScaleAzimuthFront(az, 1.5f), ev, 0.0f); }; - auto&& scales = GetAmbiScales(voice->mAmbiScaling); + const auto scales = GetAmbiScales(voice->mAmbiScaling); auto coeffs = calc_coeffs(Device->mRenderMode); if(!(coverage > 0.0f)) diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 04b88f66..bc25963e 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -93,28 +93,28 @@ void LoadSamples(float *RESTRICT dst, const std::byte *src, const size_t srcstep } -inline auto& GetAmbiScales(AmbiScaling scaletype) noexcept +constexpr auto GetAmbiScales(AmbiScaling scaletype) noexcept { switch(scaletype) { - case AmbiScaling::FuMa: return AmbiScale::FromFuMa(); - case AmbiScaling::SN3D: return AmbiScale::FromSN3D(); - case AmbiScaling::UHJ: return AmbiScale::FromUHJ(); + case AmbiScaling::FuMa: return al::span{AmbiScale::FromFuMa}; + case AmbiScaling::SN3D: return al::span{AmbiScale::FromSN3D}; + case AmbiScaling::UHJ: return al::span{AmbiScale::FromUHJ}; case AmbiScaling::N3D: break; } - return AmbiScale::FromN3D(); + return al::span{AmbiScale::FromN3D}; } -inline auto& GetAmbiLayout(AmbiLayout layouttype) noexcept +constexpr auto GetAmbiLayout(AmbiLayout layouttype) noexcept { - if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa(); - return AmbiIndex::FromACN(); + if(layouttype == AmbiLayout::FuMa) return al::span{AmbiIndex::FromFuMa}; + return al::span{AmbiIndex::FromACN}; } -inline auto& GetAmbi2DLayout(AmbiLayout layouttype) noexcept +constexpr auto GetAmbi2DLayout(AmbiLayout layouttype) noexcept { - if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D(); - return AmbiIndex::FromACN2D(); + if(layouttype == AmbiLayout::FuMa) return al::span{AmbiIndex::FromFuMa2D}; + return al::span{AmbiIndex::FromACN2D}; } @@ -453,7 +453,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot } mOutTarget = target.Main->Buffer; - auto&& scales = GetAmbiScales(mAmbiScaling); + const auto scales = GetAmbiScales(mAmbiScaling); const uint8_t *index_map{Is2DAmbisonic(mChannels) ? GetAmbi2DLayout(mAmbiLayout).data() : GetAmbiLayout(mAmbiLayout).data()}; diff --git a/alc/panning.cpp b/alc/panning.cpp index 46a840bd..871fef65 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -314,17 +314,17 @@ void InitDistanceComp(ALCdevice *device, const al::span channels, } -inline auto& GetAmbiScales(DevAmbiScaling scaletype) noexcept +constexpr auto GetAmbiScales(DevAmbiScaling scaletype) noexcept { - if(scaletype == DevAmbiScaling::FuMa) return AmbiScale::FromFuMa(); - if(scaletype == DevAmbiScaling::SN3D) return AmbiScale::FromSN3D(); - return AmbiScale::FromN3D(); + if(scaletype == DevAmbiScaling::FuMa) return al::span{AmbiScale::FromFuMa}; + if(scaletype == DevAmbiScaling::SN3D) return al::span{AmbiScale::FromSN3D}; + return al::span{AmbiScale::FromN3D}; } -inline auto& GetAmbiLayout(DevAmbiLayout layouttype) noexcept +constexpr auto GetAmbiLayout(DevAmbiLayout layouttype) noexcept { - if(layouttype == DevAmbiLayout::FuMa) return AmbiIndex::FromFuMa(); - return AmbiIndex::FromACN(); + if(layouttype == DevAmbiLayout::FuMa) return al::span{AmbiIndex::FromFuMa}; + return al::span{AmbiIndex::FromACN}; } @@ -355,8 +355,8 @@ DecoderView MakeDecoderView(ALCdevice *device, const AmbDecConf *conf, const auto num_coeffs = decoder.mIs3D ? AmbiChannelsFromOrder(decoder.mOrder) : Ambi2DChannelsFromOrder(decoder.mOrder); - const auto idx_map = decoder.mIs3D ? AmbiIndex::FromACN().data() - : AmbiIndex::FromACN2D().data(); + const auto idx_map = decoder.mIs3D ? AmbiIndex::FromACN.data() + : AmbiIndex::FromACN2D.data(); const auto hfmatrix = conf->HFMatrix; const auto lfmatrix = conf->LFMatrix; @@ -601,13 +601,13 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= case DevFmtX714: decoder = X714Config; break; case DevFmtX3D71: decoder = X3D71Config; break; case DevFmtAmbi3D: - auto&& acnmap = GetAmbiLayout(device->mAmbiLayout); - auto&& n3dscale = GetAmbiScales(device->mAmbiScale); + const auto acnmap = GetAmbiLayout(device->mAmbiLayout); + const auto n3dscale = GetAmbiScales(device->mAmbiScale); /* For DevFmtAmbi3D, the ambisonic order is already set. */ const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)}; std::transform(acnmap.begin(), acnmap.begin()+count, std::begin(device->Dry.AmbiMap), - [&n3dscale](const uint8_t &acn) noexcept -> BFChannelConfig + [n3dscale](const uint8_t &acn) noexcept -> BFChannelConfig { return BFChannelConfig{1.0f/n3dscale[acn], acn}; }); AllocChannels(device, count, 0); device->m2DMixing = false; @@ -640,8 +640,8 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= continue; } - auto ordermap = decoder.mIs3D ? AmbiIndex::OrderFromChannel().data() - : AmbiIndex::OrderFrom2DChannel().data(); + auto ordermap = decoder.mIs3D ? AmbiIndex::OrderFromChannel.data() + : AmbiIndex::OrderFrom2DChannel.data(); chancoeffs.resize(maxz(chancoeffs.size(), idx+1u), ChannelDec{}); al::span src{decoder.mCoeffs[i]}; @@ -663,11 +663,11 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= device->mAmbiOrder = decoder.mOrder; device->m2DMixing = !decoder.mIs3D; - const al::span acnmap{decoder.mIs3D ? AmbiIndex::FromACN().data() : - AmbiIndex::FromACN2D().data(), ambicount}; - auto&& coeffscale = GetAmbiScales(decoder.mScaling); + const al::span acnmap{decoder.mIs3D ? AmbiIndex::FromACN.data() : + AmbiIndex::FromACN2D.data(), ambicount}; + const auto coeffscale = GetAmbiScales(decoder.mScaling); std::transform(acnmap.begin(), acnmap.end(), std::begin(device->Dry.AmbiMap), - [&coeffscale](const uint8_t &acn) noexcept + [coeffscale](const uint8_t &acn) noexcept { return BFChannelConfig{1.0f/coeffscale[acn], acn}; }); AllocChannels(device, ambicount, device->channelsFromFmt()); @@ -902,7 +902,7 @@ void InitHrtfPanning(ALCdevice *device) device->m2DMixing = false; const size_t count{AmbiChannelsFromOrder(ambi_order)}; - std::transform(AmbiIndex::FromACN().begin(), AmbiIndex::FromACN().begin()+count, + std::transform(AmbiIndex::FromACN.begin(), AmbiIndex::FromACN.begin()+count, std::begin(device->Dry.AmbiMap), [](const uint8_t &index) noexcept { return BFChannelConfig{1.0f, index}; } ); @@ -925,10 +925,10 @@ void InitUhjPanning(ALCdevice *device) device->mAmbiOrder = 1; device->m2DMixing = true; - auto acnmap_begin = AmbiIndex::FromFuMa2D().begin(); + auto acnmap_begin = AmbiIndex::FromFuMa2D.begin(); std::transform(acnmap_begin, acnmap_begin + count, std::begin(device->Dry.AmbiMap), [](const uint8_t &acn) noexcept -> BFChannelConfig - { return BFChannelConfig{1.0f/AmbiScale::FromUHJ()[acn], acn}; }); + { return BFChannelConfig{1.0f/AmbiScale::FromUHJ[acn], acn}; }); AllocChannels(device, count, device->channelsFromFmt()); } @@ -1155,7 +1155,7 @@ void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context) slot->mWetBuffer.resize(count); - auto acnmap_begin = AmbiIndex::FromACN().begin(); + auto acnmap_begin = AmbiIndex::FromACN.begin(); auto iter = std::transform(acnmap_begin, acnmap_begin + count, slot->Wet.AmbiMap.begin(), [](const uint8_t &acn) noexcept -> BFChannelConfig { return BFChannelConfig{1.0f, acn}; }); diff --git a/core/ambidefs.h b/core/ambidefs.h index 3af26258..bea1a312 100644 --- a/core/ambidefs.h +++ b/core/ambidefs.h @@ -48,70 +48,54 @@ inline constexpr size_t MaxAmbi2DChannels{Ambi2DChannelsFromOrder(MaxAmbiOrder)} * coefficients should be divided by these values to get proper scalings. */ struct AmbiScale { - static auto& FromN3D() noexcept - { - static constexpr const std::array ret{{ - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f - }}; - return ret; - } - static auto& FromSN3D() noexcept - { - static constexpr const std::array ret{{ - 1.000000000f, /* ACN 0, sqrt(1) */ - 1.732050808f, /* ACN 1, sqrt(3) */ - 1.732050808f, /* ACN 2, sqrt(3) */ - 1.732050808f, /* ACN 3, sqrt(3) */ - 2.236067978f, /* ACN 4, sqrt(5) */ - 2.236067978f, /* ACN 5, sqrt(5) */ - 2.236067978f, /* ACN 6, sqrt(5) */ - 2.236067978f, /* ACN 7, sqrt(5) */ - 2.236067978f, /* ACN 8, sqrt(5) */ - 2.645751311f, /* ACN 9, sqrt(7) */ - 2.645751311f, /* ACN 10, sqrt(7) */ - 2.645751311f, /* ACN 11, sqrt(7) */ - 2.645751311f, /* ACN 12, sqrt(7) */ - 2.645751311f, /* ACN 13, sqrt(7) */ - 2.645751311f, /* ACN 14, sqrt(7) */ - 2.645751311f, /* ACN 15, sqrt(7) */ - }}; - return ret; - } - static auto& FromFuMa() noexcept - { - static constexpr const std::array ret{{ - 1.414213562f, /* ACN 0 (W), sqrt(2) */ - 1.732050808f, /* ACN 1 (Y), sqrt(3) */ - 1.732050808f, /* ACN 2 (Z), sqrt(3) */ - 1.732050808f, /* ACN 3 (X), sqrt(3) */ - 1.936491673f, /* ACN 4 (V), sqrt(15)/2 */ - 1.936491673f, /* ACN 5 (T), sqrt(15)/2 */ - 2.236067978f, /* ACN 6 (R), sqrt(5) */ - 1.936491673f, /* ACN 7 (S), sqrt(15)/2 */ - 1.936491673f, /* ACN 8 (U), sqrt(15)/2 */ - 2.091650066f, /* ACN 9 (Q), sqrt(35/8) */ - 1.972026594f, /* ACN 10 (O), sqrt(35)/3 */ - 2.231093404f, /* ACN 11 (M), sqrt(224/45) */ - 2.645751311f, /* ACN 12 (K), sqrt(7) */ - 2.231093404f, /* ACN 13 (L), sqrt(224/45) */ - 1.972026594f, /* ACN 14 (N), sqrt(35)/3 */ - 2.091650066f, /* ACN 15 (P), sqrt(35/8) */ - }}; - return ret; - } - static auto& FromUHJ() noexcept - { - static constexpr const std::array ret{{ - 1.000000000f, /* ACN 0 (W), sqrt(1) */ - 1.224744871f, /* ACN 1 (Y), sqrt(3/2) */ - 1.224744871f, /* ACN 2 (Z), sqrt(3/2) */ - 1.224744871f, /* ACN 3 (X), sqrt(3/2) */ - /* Higher orders not relevant for UHJ. */ - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - }}; - return ret; - } + static inline constexpr std::array FromN3D{{ + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f + }}; + static inline constexpr std::array FromSN3D{{ + 1.000000000f, /* ACN 0, sqrt(1) */ + 1.732050808f, /* ACN 1, sqrt(3) */ + 1.732050808f, /* ACN 2, sqrt(3) */ + 1.732050808f, /* ACN 3, sqrt(3) */ + 2.236067978f, /* ACN 4, sqrt(5) */ + 2.236067978f, /* ACN 5, sqrt(5) */ + 2.236067978f, /* ACN 6, sqrt(5) */ + 2.236067978f, /* ACN 7, sqrt(5) */ + 2.236067978f, /* ACN 8, sqrt(5) */ + 2.645751311f, /* ACN 9, sqrt(7) */ + 2.645751311f, /* ACN 10, sqrt(7) */ + 2.645751311f, /* ACN 11, sqrt(7) */ + 2.645751311f, /* ACN 12, sqrt(7) */ + 2.645751311f, /* ACN 13, sqrt(7) */ + 2.645751311f, /* ACN 14, sqrt(7) */ + 2.645751311f, /* ACN 15, sqrt(7) */ + }}; + static inline constexpr std::array FromFuMa{{ + 1.414213562f, /* ACN 0 (W), sqrt(2) */ + 1.732050808f, /* ACN 1 (Y), sqrt(3) */ + 1.732050808f, /* ACN 2 (Z), sqrt(3) */ + 1.732050808f, /* ACN 3 (X), sqrt(3) */ + 1.936491673f, /* ACN 4 (V), sqrt(15)/2 */ + 1.936491673f, /* ACN 5 (T), sqrt(15)/2 */ + 2.236067978f, /* ACN 6 (R), sqrt(5) */ + 1.936491673f, /* ACN 7 (S), sqrt(15)/2 */ + 1.936491673f, /* ACN 8 (U), sqrt(15)/2 */ + 2.091650066f, /* ACN 9 (Q), sqrt(35/8) */ + 1.972026594f, /* ACN 10 (O), sqrt(35)/3 */ + 2.231093404f, /* ACN 11 (M), sqrt(224/45) */ + 2.645751311f, /* ACN 12 (K), sqrt(7) */ + 2.231093404f, /* ACN 13 (L), sqrt(224/45) */ + 1.972026594f, /* ACN 14 (N), sqrt(35)/3 */ + 2.091650066f, /* ACN 15 (P), sqrt(35/8) */ + }}; + static inline constexpr std::array FromUHJ{{ + 1.000000000f, /* ACN 0 (W), sqrt(1) */ + 1.224744871f, /* ACN 1 (Y), sqrt(3/2) */ + 1.224744871f, /* ACN 2 (Z), sqrt(3/2) */ + 1.224744871f, /* ACN 3 (X), sqrt(3/2) */ + /* Higher orders not relevant for UHJ. */ + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, + }}; /* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */ static std::array GetHFOrderScales(const uint src_order, @@ -127,72 +111,49 @@ struct AmbiScale { }; struct AmbiIndex { - static auto& FromFuMa() noexcept - { - static constexpr const std::array ret{{ - 0, /* W */ - 3, /* X */ - 1, /* Y */ - 2, /* Z */ - 6, /* R */ - 7, /* S */ - 5, /* T */ - 8, /* U */ - 4, /* V */ - 12, /* K */ - 13, /* L */ - 11, /* M */ - 14, /* N */ - 10, /* O */ - 15, /* P */ - 9, /* Q */ - }}; - return ret; - } - static auto& FromFuMa2D() noexcept - { - static constexpr const std::array ret{{ - 0, /* W */ - 3, /* X */ - 1, /* Y */ - 8, /* U */ - 4, /* V */ - 15, /* P */ - 9, /* Q */ - }}; - return ret; - } - - static auto& FromACN() noexcept - { - static constexpr const std::array ret{{ - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15 - }}; - return ret; - } - static auto& FromACN2D() noexcept - { - static constexpr const std::array ret{{ - 0, 1,3, 4,8, 9,15 - }}; - return ret; - } - - static auto& OrderFromChannel() noexcept - { - static constexpr const std::array ret{{ - 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3, - }}; - return ret; - } - static auto& OrderFrom2DChannel() noexcept - { - static constexpr const std::array ret{{ - 0, 1,1, 2,2, 3,3, - }}; - return ret; - } + static inline constexpr std::array FromFuMa{{ + 0, /* W */ + 3, /* X */ + 1, /* Y */ + 2, /* Z */ + 6, /* R */ + 7, /* S */ + 5, /* T */ + 8, /* U */ + 4, /* V */ + 12, /* K */ + 13, /* L */ + 11, /* M */ + 14, /* N */ + 10, /* O */ + 15, /* P */ + 9, /* Q */ + }}; + static inline constexpr std::array FromFuMa2D{{ + 0, /* W */ + 3, /* X */ + 1, /* Y */ + 8, /* U */ + 4, /* V */ + 15, /* P */ + 9, /* Q */ + }}; + + static inline constexpr std::array FromACN{{ + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 + }}; + static inline constexpr std::array FromACN2D{{ + 0, 1,3, 4,8, 9,15 + }}; + + + static inline constexpr std::array OrderFromChannel{{ + 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3, + }}; + static inline constexpr std::array OrderFrom2DChannel{{ + 0, 1,1, 2,2, 3,3, + }}; }; diff --git a/core/hrtf.cpp b/core/hrtf.cpp index 7d11ee19..f131e72d 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -289,7 +289,7 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const uint irSize, const bool mChannels[0].mSplitter.init(static_cast(xover_norm)); for(size_t i{0};i < mChannels.size();++i) { - const size_t order{AmbiIndex::OrderFromChannel()[i]}; + const size_t order{AmbiIndex::OrderFromChannel[i]}; mChannels[i].mSplitter = mChannels[0].mSplitter; mChannels[i].mHfScale = AmbiOrderHFGain[order]; } diff --git a/core/voice.cpp b/core/voice.cpp index 65986cd1..92da3e76 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -1273,7 +1273,7 @@ void Voice::prepare(DeviceBase *device) else if(mAmbiOrder && device->mAmbiOrder > mAmbiOrder) { const uint8_t *OrderFromChan{Is2DAmbisonic(mFmtChannels) ? - AmbiIndex::OrderFrom2DChannel().data() : AmbiIndex::OrderFromChannel().data()}; + AmbiIndex::OrderFrom2DChannel.data() : AmbiIndex::OrderFromChannel.data()}; const auto scales = AmbiScale::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder, device->m2DMixing); -- cgit v1.2.3 From 197691365d112e170a8478fbbdcb38fd3826e418 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 22 Oct 2023 13:56:05 -0700 Subject: Use a byte for the channel index --- alc/alu.cpp | 18 +++++++++--------- alc/effects/dedicated.cpp | 4 ++-- alc/panning.cpp | 2 +- core/device.h | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'alc/panning.cpp') diff --git a/alc/alu.cpp b/alc/alu.cpp index 7aefcfb5..203bd7cf 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -279,8 +279,8 @@ ResamplerFunc PrepareResampler(Resampler resampler, uint increment, InterpState void DeviceBase::ProcessHrtf(const size_t SamplesToDo) { /* HRTF is stereo output only. */ - const uint lidx{RealOut.ChannelIndex[FrontLeft]}; - const uint ridx{RealOut.ChannelIndex[FrontRight]}; + const size_t lidx{RealOut.ChannelIndex[FrontLeft]}; + const size_t ridx{RealOut.ChannelIndex[FrontRight]}; MixDirectHrtf(RealOut.Buffer[lidx], RealOut.Buffer[ridx], Dry.Buffer, HrtfAccumData, mHrtfState->mTemp.data(), mHrtfState->mChannels.data(), mHrtfState->mIrSize, SamplesToDo); @@ -294,9 +294,9 @@ void DeviceBase::ProcessAmbiDec(const size_t SamplesToDo) void DeviceBase::ProcessAmbiDecStablized(const size_t SamplesToDo) { /* Decode with front image stablization. */ - const uint lidx{RealOut.ChannelIndex[FrontLeft]}; - const uint ridx{RealOut.ChannelIndex[FrontRight]}; - const uint cidx{RealOut.ChannelIndex[FrontCenter]}; + const size_t lidx{RealOut.ChannelIndex[FrontLeft]}; + const size_t ridx{RealOut.ChannelIndex[FrontRight]}; + const size_t cidx{RealOut.ChannelIndex[FrontCenter]}; AmbiDecoder->processStablize(RealOut.Buffer, Dry.Buffer.data(), lidx, ridx, cidx, SamplesToDo); @@ -305,8 +305,8 @@ void DeviceBase::ProcessAmbiDecStablized(const size_t SamplesToDo) void DeviceBase::ProcessUhj(const size_t SamplesToDo) { /* UHJ is stereo output only. */ - const uint lidx{RealOut.ChannelIndex[FrontLeft]}; - const uint ridx{RealOut.ChannelIndex[FrontRight]}; + const size_t lidx{RealOut.ChannelIndex[FrontLeft]}; + const size_t ridx{RealOut.ChannelIndex[FrontRight]}; /* Encode to stereo-compatible 2-channel UHJ output. */ mUhjEncoder->encode(RealOut.Buffer[lidx].data(), RealOut.Buffer[ridx].data(), @@ -319,8 +319,8 @@ void DeviceBase::ProcessBs2b(const size_t SamplesToDo) AmbiDecoder->process(RealOut.Buffer, Dry.Buffer.data(), SamplesToDo); /* BS2B is stereo output only. */ - const uint lidx{RealOut.ChannelIndex[FrontLeft]}; - const uint ridx{RealOut.ChannelIndex[FrontRight]}; + const size_t lidx{RealOut.ChannelIndex[FrontLeft]}; + const size_t ridx{RealOut.ChannelIndex[FrontRight]}; /* Now apply the BS2B binaural/crossfeed filter. */ bs2b_cross_feed(Bs2b.get(), RealOut.Buffer[lidx].data(), RealOut.Buffer[ridx].data(), diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp index 9ac68bec..a9131bfa 100644 --- a/alc/effects/dedicated.cpp +++ b/alc/effects/dedicated.cpp @@ -74,7 +74,7 @@ void DedicatedState::update(const ContextBase*, const EffectSlot *slot, if(slot->EffectType == EffectSlotType::DedicatedLFE) { - const uint idx{target.RealOut ? target.RealOut->ChannelIndex[LFE] : InvalidChannelIndex}; + const size_t idx{target.RealOut ? target.RealOut->ChannelIndex[LFE] : InvalidChannelIndex}; if(idx != InvalidChannelIndex) { mOutTarget = target.RealOut->Buffer; @@ -85,7 +85,7 @@ void DedicatedState::update(const ContextBase*, const EffectSlot *slot, { /* Dialog goes to the front-center speaker if it exists, otherwise it * plays from the front-center location. */ - const uint idx{target.RealOut ? target.RealOut->ChannelIndex[FrontCenter] + const size_t idx{target.RealOut ? target.RealOut->ChannelIndex[FrontCenter] : InvalidChannelIndex}; if(idx != InvalidChannelIndex) { diff --git a/alc/panning.cpp b/alc/panning.cpp index 871fef65..b512a42a 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -677,7 +677,7 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= /* Only enable the stablizer if the decoder does not output to the * front-center channel. */ - const auto cidx = device->RealOut.ChannelIndex[FrontCenter]; + const size_t cidx{device->RealOut.ChannelIndex[FrontCenter]}; bool hasfc{false}; if(cidx < chancoeffs.size()) { diff --git a/core/device.h b/core/device.h index b088e130..b1ffc9ce 100644 --- a/core/device.h +++ b/core/device.h @@ -94,7 +94,7 @@ struct DistanceComp { }; -constexpr uint InvalidChannelIndex{~0u}; +constexpr uint8_t InvalidChannelIndex{static_cast(~0u)}; struct BFChannelConfig { float Scale; @@ -112,8 +112,8 @@ struct MixParams { * source is expected to be a 3D ACN/N3D ambisonic buffer, and for each * channel [0...count), the given functor is called with the source channel * index, destination channel index, and the gain for that channel. If the - * destination channel is INVALID_CHANNEL_INDEX, the given source channel - * is not used for output. + * destination channel is InvalidChannelIndex, the given source channel is + * not used for output. */ template void setAmbiMixParams(const MixParams &inmix, const float gainbase, F func) const @@ -122,14 +122,14 @@ struct MixParams { const size_t numOut{Buffer.size()}; for(size_t i{0};i < numIn;++i) { - auto idx = InvalidChannelIndex; - auto gain = 0.0f; + uint8_t idx{InvalidChannelIndex}; + float gain{0.0f}; for(size_t j{0};j < numOut;++j) { if(AmbiMap[j].Index == inmix.AmbiMap[i].Index) { - idx = static_cast(j); + idx = static_cast(j); gain = AmbiMap[j].Scale * gainbase; break; } @@ -141,7 +141,7 @@ struct MixParams { struct RealMixParams { al::span RemixMap; - std::array ChannelIndex{}; + std::array ChannelIndex{}; al::span Buffer; }; @@ -329,9 +329,9 @@ struct DeviceBase { /** * Returns the index for the given channel name (e.g. FrontCenter), or - * INVALID_CHANNEL_INDEX if it doesn't exist. + * InvalidChannelIndex if it doesn't exist. */ - uint channelIdxByName(Channel chan) const noexcept + uint8_t channelIdxByName(Channel chan) const noexcept { return RealOut.ChannelIndex[chan]; } DISABLE_ALLOC() -- cgit v1.2.3