summaryrefslogtreecommitdiff
path: root/src/pcm/PcmExport.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-02-26 18:17:11 +0100
committerMax Kellermann <max@duempel.org>2016-02-27 07:42:09 +0100
commitfb4f02cd388c13093deebc4d7168600f259845a5 (patch)
tree7f6d9ec7923e22f7f5d0e68198bb91bdb51b3c66 /src/pcm/PcmExport.cxx
parentd1be643c0de70c865043127edb042a02f51d3c6d (diff)
pcm/PcmExport: add flag to export to DSD_U32
Diffstat (limited to 'src/pcm/PcmExport.cxx')
-rw-r--r--src/pcm/PcmExport.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/pcm/PcmExport.cxx b/src/pcm/PcmExport.cxx
index b40129ad1..5a9bf4558 100644
--- a/src/pcm/PcmExport.cxx
+++ b/src/pcm/PcmExport.cxx
@@ -25,6 +25,7 @@
#include "util/ConstBuffer.hxx"
#ifdef ENABLE_DSD
+#include "PcmDsd.hxx"
#include "PcmDop.hxx"
#endif
@@ -42,7 +43,15 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
: SampleFormat::UNDEFINED;
#ifdef ENABLE_DSD
+ assert(!params.dsd_u32 || !params.dop);
assert(!params.dop || audio_valid_channel_count(_channels));
+
+ dsd_u32 = params.dsd_u32 && sample_format == SampleFormat::DSD;
+ if (dsd_u32)
+ /* after the conversion to DSD_U32, the DSD samples
+ are stuffed inside fake 32 bit samples */
+ sample_format = SampleFormat::S32;
+
dop = params.dop && sample_format == SampleFormat::DSD;
if (dop)
/* after the conversion to DoP, the DSD
@@ -77,6 +86,9 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const
return audio_format.channels * 3;
#ifdef ENABLE_DSD
+ if (dsd_u32)
+ return channels * 4;
+
if (dop)
/* the DSD-over-USB draft says that DSD 1-bit samples
are enclosed within 24 bit samples, and MPD's
@@ -96,6 +108,11 @@ PcmExport::Export(ConstBuffer<void> data)
alsa_channel_order, channels);
#ifdef ENABLE_DSD
+ if (dsd_u32)
+ data = Dsd8To32(dop_buffer, channels,
+ ConstBuffer<uint8_t>::FromVoid(data))
+ .ToVoid();
+
if (dop)
data = pcm_dsd_to_dop(dop_buffer, channels,
ConstBuffer<uint8_t>::FromVoid(data))