diff options
author | Max Kellermann <max@musicpd.org> | 2020-01-17 19:12:16 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-01-17 19:15:44 +0100 |
commit | a37d22de8adc2d33236154b3139862055c9c06d4 (patch) | |
tree | a0e0082f10b3d9fa0d4fb8dc229df9db0b3e399f /src | |
parent | 452e1c1a6f4a1a099f7759acbe8b1b3fdf9d5a8c (diff) |
pcm/Convert: choose pcm2dsd float/integer according to dest_format
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm/Convert.cxx | 11 | ||||
-rw-r--r-- | src/pcm/Convert.hxx | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/pcm/Convert.cxx b/src/pcm/Convert.cxx index d464d210e..6f550ba94 100644 --- a/src/pcm/Convert.cxx +++ b/src/pcm/Convert.cxx @@ -41,7 +41,10 @@ PcmConvert::PcmConvert(const AudioFormat _src_format, AudioFormat format = _src_format; if (format.format == SampleFormat::DSD) { #ifdef ENABLE_DSD - format.format = SampleFormat::FLOAT; + dsd2pcm_float = dest_format.format == SampleFormat::FLOAT; + format.format = dsd2pcm_float + ? SampleFormat::FLOAT + : SampleFormat::S24_P32; #else throw std::runtime_error("DSD support is disabled"); #endif @@ -115,11 +118,13 @@ PcmConvert::Convert(ConstBuffer<void> buffer) #ifdef ENABLE_DSD if (src_format.format == SampleFormat::DSD) { auto s = ConstBuffer<uint8_t>::FromVoid(buffer); - auto d = dsd.ToFloat(src_format.channels, s); + auto d = dsd2pcm_float + ? dsd.ToFloat(src_format.channels, s).ToVoid() + : dsd.ToS24(src_format.channels, s).ToVoid(); if (d.IsNull()) throw std::runtime_error("DSD to PCM conversion failed"); - buffer = d.ToVoid(); + buffer = d; } #endif diff --git a/src/pcm/Convert.hxx b/src/pcm/Convert.hxx index c22241054..4a1143338 100644 --- a/src/pcm/Convert.hxx +++ b/src/pcm/Convert.hxx @@ -51,6 +51,10 @@ class PcmConvert { bool enable_resampler, enable_format, enable_channels; +#ifdef ENABLE_DSD + bool dsd2pcm_float; +#endif + public: /** |