diff options
author | Max Kellermann <max@musicpd.org> | 2020-01-14 23:26:34 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-01-14 23:26:34 +0100 |
commit | becd81f7710f49bddddfa1f171515c85a48de8a1 (patch) | |
tree | 0cfdca04da8168242d42ba58cc120a4545c2df15 /src/pcm | |
parent | 2073a2c1b0978fb1b66803d5aa54b511d072530a (diff) |
pcm/PcmDsd: manage Dsd2Pcm instances, not pointers
Diffstat (limited to 'src/pcm')
-rw-r--r-- | src/pcm/PcmDsd.cxx | 25 | ||||
-rw-r--r-- | src/pcm/PcmDsd.hxx | 7 |
2 files changed, 7 insertions, 25 deletions
diff --git a/src/pcm/PcmDsd.cxx b/src/pcm/PcmDsd.cxx index e742ed1fa..7348c5f61 100644 --- a/src/pcm/PcmDsd.cxx +++ b/src/pcm/PcmDsd.cxx @@ -23,23 +23,11 @@ #include <assert.h> -PcmDsd::PcmDsd() noexcept -{ - dsd2pcm.fill(nullptr); -} - -PcmDsd::~PcmDsd() noexcept -{ - for (auto i : dsd2pcm) - delete i; -} - void PcmDsd::Reset() noexcept { - for (auto i : dsd2pcm) - if (i != nullptr) - i->Reset(); + for (auto &i : dsd2pcm) + i.Reset(); } ConstBuffer<float> @@ -56,12 +44,9 @@ PcmDsd::ToFloat(unsigned channels, ConstBuffer<uint8_t> src) noexcept float *dest = buffer.GetT<float>(num_samples); for (unsigned c = 0; c < channels; ++c) { - if (dsd2pcm[c] == nullptr) - dsd2pcm[c] = new Dsd2Pcm(); - - dsd2pcm[c]->Translate(num_frames, - src.data + c, channels, - dest + c, channels); + dsd2pcm[c].Translate(num_frames, + src.data + c, channels, + dest + c, channels); } return { dest, num_samples }; diff --git a/src/pcm/PcmDsd.hxx b/src/pcm/PcmDsd.hxx index cf6365297..6b36944b1 100644 --- a/src/pcm/PcmDsd.hxx +++ b/src/pcm/PcmDsd.hxx @@ -22,13 +22,13 @@ #include "Buffer.hxx" #include "ChannelDefs.hxx" +#include "Dsd2Pcm.hxx" #include <array> #include <stdint.h> template<typename T> struct ConstBuffer; -class Dsd2Pcm; /** * Wrapper for the dsd2pcm library. @@ -36,12 +36,9 @@ class Dsd2Pcm; class PcmDsd { PcmBuffer buffer; - std::array<Dsd2Pcm *, MAX_CHANNELS> dsd2pcm; + std::array<Dsd2Pcm, MAX_CHANNELS> dsd2pcm; public: - PcmDsd() noexcept; - ~PcmDsd() noexcept; - void Reset() noexcept; ConstBuffer<float> ToFloat(unsigned channels, |