pcm/Export: halve the sample rate for DoP
Move this sample rate fixup from the ALSA output plugin to PcmExport, where it belongs.
This commit is contained in:
parent
2b43ceb6c6
commit
9c4df66925
|
@ -666,7 +666,6 @@ AlsaOutput::SetupDop(const AudioFormat audio_format,
|
||||||
|
|
||||||
AudioFormat dop_format = audio_format;
|
AudioFormat dop_format = audio_format;
|
||||||
dop_format.format = SampleFormat::S24_P32;
|
dop_format.format = SampleFormat::S24_P32;
|
||||||
dop_format.sample_rate /= 2;
|
|
||||||
|
|
||||||
const AudioFormat check = dop_format;
|
const AudioFormat check = dop_format;
|
||||||
|
|
||||||
|
@ -698,11 +697,12 @@ AlsaOutput::SetupOrDop(AudioFormat &audio_format, PcmExport::Params ¶ms)
|
||||||
std::exception_ptr dop_error;
|
std::exception_ptr dop_error;
|
||||||
if (dop && audio_format.format == SampleFormat::DSD) {
|
if (dop && audio_format.format == SampleFormat::DSD) {
|
||||||
try {
|
try {
|
||||||
SetupDop(audio_format, params);
|
|
||||||
params.dop = true;
|
params.dop = true;
|
||||||
|
SetupDop(audio_format, params);
|
||||||
return;
|
return;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
dop_error = std::current_exception();
|
dop_error = std::current_exception();
|
||||||
|
params.dop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,11 @@ PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const
|
||||||
/* DSD_U32 combines four 8-bit "samples" in one 32-bit
|
/* DSD_U32 combines four 8-bit "samples" in one 32-bit
|
||||||
"sample" */
|
"sample" */
|
||||||
sample_rate /= 4;
|
sample_rate /= 4;
|
||||||
|
|
||||||
|
if (dop)
|
||||||
|
/* DoP packs two 8-bit "samples" in one 24-bit
|
||||||
|
"sample" */
|
||||||
|
sample_rate /= 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return sample_rate;
|
return sample_rate;
|
||||||
|
@ -117,6 +122,9 @@ PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const
|
||||||
#ifdef ENABLE_DSD
|
#ifdef ENABLE_DSD
|
||||||
if (dsd_u32)
|
if (dsd_u32)
|
||||||
sample_rate *= 4;
|
sample_rate *= 4;
|
||||||
|
|
||||||
|
if (dop)
|
||||||
|
sample_rate *= 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return sample_rate;
|
return sample_rate;
|
||||||
|
|
|
@ -175,6 +175,9 @@ PcmExportTest::TestDop()
|
||||||
PcmExport::Params params;
|
PcmExport::Params params;
|
||||||
params.dop = true;
|
params.dop = true;
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(params.CalcOutputSampleRate(705600u), 176400u);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(params.CalcInputSampleRate(176400u), 705600u);
|
||||||
|
|
||||||
PcmExport e;
|
PcmExport e;
|
||||||
e.Open(SampleFormat::DSD, 2, params);
|
e.Open(SampleFormat::DSD, 2, params);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue