Commit becd81f7 authored by Max Kellermann's avatar Max Kellermann

pcm/PcmDsd: manage Dsd2Pcm instances, not pointers

parent 2073a2c1
......@@ -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 };
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment