diff options
author | Max Kellermann <max@musicpd.org> | 2017-01-11 00:11:43 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-01-11 10:33:23 +0100 |
commit | 9c4df669253e1b01f20ff4d496c15a8bed4a00ac (patch) | |
tree | be9fda03d546c7555ad6d9ccff2ccab2ebbfa4e1 /src | |
parent | 2b43ceb6c68e93feff830d2946abc8dc8f069421 (diff) |
pcm/Export: halve the sample rate for DoP
Move this sample rate fixup from the ALSA output plugin to PcmExport,
where it belongs.
Diffstat (limited to 'src')
-rw-r--r-- | src/output/plugins/AlsaOutputPlugin.cxx | 4 | ||||
-rw-r--r-- | src/pcm/PcmExport.cxx | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 6b5405f87..90b74c0bb 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -666,7 +666,6 @@ AlsaOutput::SetupDop(const AudioFormat audio_format, AudioFormat dop_format = audio_format; dop_format.format = SampleFormat::S24_P32; - dop_format.sample_rate /= 2; const AudioFormat check = dop_format; @@ -698,11 +697,12 @@ AlsaOutput::SetupOrDop(AudioFormat &audio_format, PcmExport::Params ¶ms) std::exception_ptr dop_error; if (dop && audio_format.format == SampleFormat::DSD) { try { - SetupDop(audio_format, params); params.dop = true; + SetupDop(audio_format, params); return; } catch (...) { dop_error = std::current_exception(); + params.dop = false; } } diff --git a/src/pcm/PcmExport.cxx b/src/pcm/PcmExport.cxx index ed8ab1707..254995d38 100644 --- a/src/pcm/PcmExport.cxx +++ b/src/pcm/PcmExport.cxx @@ -106,6 +106,11 @@ PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const /* DSD_U32 combines four 8-bit "samples" in one 32-bit "sample" */ sample_rate /= 4; + + if (dop) + /* DoP packs two 8-bit "samples" in one 24-bit + "sample" */ + sample_rate /= 2; #endif return sample_rate; @@ -117,6 +122,9 @@ PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const #ifdef ENABLE_DSD if (dsd_u32) sample_rate *= 4; + + if (dop) + sample_rate *= 2; #endif return sample_rate; |