pcm/PcmDsd: manage Dsd2Pcm instances, not pointers
This commit is contained in:
parent
2073a2c1b0
commit
becd81f771
@ -23,23 +23,11 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
PcmDsd::PcmDsd() noexcept
|
|
||||||
{
|
|
||||||
dsd2pcm.fill(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
PcmDsd::~PcmDsd() noexcept
|
|
||||||
{
|
|
||||||
for (auto i : dsd2pcm)
|
|
||||||
delete i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PcmDsd::Reset() noexcept
|
PcmDsd::Reset() noexcept
|
||||||
{
|
{
|
||||||
for (auto i : dsd2pcm)
|
for (auto &i : dsd2pcm)
|
||||||
if (i != nullptr)
|
i.Reset();
|
||||||
i->Reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstBuffer<float>
|
ConstBuffer<float>
|
||||||
@ -56,12 +44,9 @@ PcmDsd::ToFloat(unsigned channels, ConstBuffer<uint8_t> src) noexcept
|
|||||||
float *dest = buffer.GetT<float>(num_samples);
|
float *dest = buffer.GetT<float>(num_samples);
|
||||||
|
|
||||||
for (unsigned c = 0; c < channels; ++c) {
|
for (unsigned c = 0; c < channels; ++c) {
|
||||||
if (dsd2pcm[c] == nullptr)
|
dsd2pcm[c].Translate(num_frames,
|
||||||
dsd2pcm[c] = new Dsd2Pcm();
|
src.data + c, channels,
|
||||||
|
dest + c, channels);
|
||||||
dsd2pcm[c]->Translate(num_frames,
|
|
||||||
src.data + c, channels,
|
|
||||||
dest + c, channels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { dest, num_samples };
|
return { dest, num_samples };
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
#include "Buffer.hxx"
|
#include "Buffer.hxx"
|
||||||
#include "ChannelDefs.hxx"
|
#include "ChannelDefs.hxx"
|
||||||
|
#include "Dsd2Pcm.hxx"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
template<typename T> struct ConstBuffer;
|
template<typename T> struct ConstBuffer;
|
||||||
class Dsd2Pcm;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for the dsd2pcm library.
|
* Wrapper for the dsd2pcm library.
|
||||||
@ -36,12 +36,9 @@ class Dsd2Pcm;
|
|||||||
class PcmDsd {
|
class PcmDsd {
|
||||||
PcmBuffer buffer;
|
PcmBuffer buffer;
|
||||||
|
|
||||||
std::array<Dsd2Pcm *, MAX_CHANNELS> dsd2pcm;
|
std::array<Dsd2Pcm, MAX_CHANNELS> dsd2pcm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PcmDsd() noexcept;
|
|
||||||
~PcmDsd() noexcept;
|
|
||||||
|
|
||||||
void Reset() noexcept;
|
void Reset() noexcept;
|
||||||
|
|
||||||
ConstBuffer<float> ToFloat(unsigned channels,
|
ConstBuffer<float> ToFloat(unsigned channels,
|
||||||
|
Loading…
Reference in New Issue
Block a user