From cb4f5d454b18fa78f35612317263b02fccf93146 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 26 Feb 2016 17:38:46 +0100 Subject: [PATCH] pcm/dsd: use std::array --- src/pcm/PcmDsd.cxx | 19 ++++++++----------- src/pcm/PcmDsd.hxx | 4 +++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/pcm/PcmDsd.cxx b/src/pcm/PcmDsd.cxx index f27c63f33..b74d812e2 100644 --- a/src/pcm/PcmDsd.cxx +++ b/src/pcm/PcmDsd.cxx @@ -20,31 +20,28 @@ #include "config.h" #include "PcmDsd.hxx" #include "dsd2pcm/dsd2pcm.h" -#include "util/Macros.hxx" #include "util/ConstBuffer.hxx" -#include - #include PcmDsd::PcmDsd() { - std::fill_n(dsd2pcm, ARRAY_SIZE(dsd2pcm), nullptr); + dsd2pcm.fill(nullptr); } PcmDsd::~PcmDsd() { - for (unsigned i = 0; i < ARRAY_SIZE(dsd2pcm); ++i) - if (dsd2pcm[i] != nullptr) - dsd2pcm_destroy(dsd2pcm[i]); + for (auto i : dsd2pcm) + if (i != nullptr) + dsd2pcm_destroy(i); } void PcmDsd::Reset() { - for (unsigned i = 0; i < ARRAY_SIZE(dsd2pcm); ++i) - if (dsd2pcm[i] != nullptr) - dsd2pcm_reset(dsd2pcm[i]); + for (auto i : dsd2pcm) + if (i != nullptr) + dsd2pcm_reset(i); } ConstBuffer @@ -53,7 +50,7 @@ PcmDsd::ToFloat(unsigned channels, ConstBuffer src) assert(!src.IsNull()); assert(!src.IsEmpty()); assert(src.size % channels == 0); - assert(channels <= ARRAY_SIZE(dsd2pcm)); + assert(channels <= dsd2pcm.max_size()); const unsigned num_samples = src.size; const unsigned num_frames = src.size / channels; diff --git a/src/pcm/PcmDsd.hxx b/src/pcm/PcmDsd.hxx index 89654ebe6..10b8a5fda 100644 --- a/src/pcm/PcmDsd.hxx +++ b/src/pcm/PcmDsd.hxx @@ -23,6 +23,8 @@ #include "check.h" #include "PcmBuffer.hxx" +#include + #include template struct ConstBuffer; @@ -33,7 +35,7 @@ template struct ConstBuffer; class PcmDsd { PcmBuffer buffer; - struct dsd2pcm_ctx_s *dsd2pcm[32]; + std::array dsd2pcm; public: PcmDsd();