From a75d35bbb06f74e58cb2232d4ca2ce47950f08cd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 10 Dec 2021 22:07:20 -0800 Subject: Use a vector in BFormatDec instead of FlexArray FlexArray would be better since it's not likely to use much memory for the array, but the std::unique_ptr makes BFormatDec a non-standard layout, causing GCC and Clang to complain. --- core/bformatdec.cpp | 4 ++-- core/bformatdec.h | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/bformatdec.cpp b/core/bformatdec.cpp index e3f8eaef..ed00566e 100644 --- a/core/bformatdec.cpp +++ b/core/bformatdec.cpp @@ -193,6 +193,6 @@ std::unique_ptr BFormatDec::Create(const size_t inchans, const al::span coeffs, const al::span coeffslf, const float xover_f0norm, std::unique_ptr stablizer) { - return std::unique_ptr{new(FamCount(inchans)) - BFormatDec{inchans, coeffs, coeffslf, xover_f0norm, std::move(stablizer)}}; + return std::make_unique(inchans, coeffs, coeffslf, xover_f0norm, + std::move(stablizer)); } diff --git a/core/bformatdec.h b/core/bformatdec.h index 2cc057f4..0231da1e 100644 --- a/core/bformatdec.h +++ b/core/bformatdec.h @@ -11,6 +11,7 @@ #include "bufferline.h" #include "devformat.h" #include "filters/splitter.h" +#include "vector.h" struct FrontStablizer; @@ -37,13 +38,18 @@ class BFormatDec { const std::unique_ptr mStablizer; const bool mDualBand{false}; - al::FlexArray mChannelDec; + /* TODO: This should ideally be a FlexArray, since ChannelDecoder is rather + * small and only a few are needed (3, 4, 5, 7, typically). But that can + * 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; +public: BFormatDec(const size_t inchans, const al::span coeffs, const al::span coeffslf, const float xover_f0norm, std::unique_ptr stablizer); -public: bool hasStablizer() const noexcept { return mStablizer != nullptr; }; /* Decodes the ambisonic input to the given output channels. */ @@ -59,7 +65,7 @@ public: const al::span coeffs, const al::span coeffslf, const float xover_f0norm, std::unique_ptr stablizer); - DEF_FAM_NEWDEL(BFormatDec, mChannelDec) + DEF_NEWDEL(BFormatDec) }; #endif /* CORE_BFORMATDEC_H */ -- cgit v1.2.3