pcm/Export: convert the DSD bools to an enum

These options are exclusive.
This commit is contained in:
Max Kellermann
2019-06-17 22:20:28 +02:00
parent c75dc4a647
commit 28e07e900f
6 changed files with 113 additions and 53 deletions

View File

@@ -558,12 +558,12 @@ AlsaOutput::SetupOrDop(AudioFormat &audio_format, PcmExport::Params &params
std::exception_ptr dop_error;
if (dop && audio_format.format == SampleFormat::DSD) {
try {
params.dop = true;
params.dsd_mode = PcmExport::DsdMode::DOP;
SetupDop(audio_format, params);
return;
} catch (...) {
dop_error = std::current_exception();
params.dop = false;
params.dsd_mode = PcmExport::DsdMode::NONE;
}
}
@@ -663,7 +663,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
snd_pcm_nonblock(pcm, 1);
#ifdef ENABLE_DSD
if (params.dop)
if (params.dsd_mode == PcmExport::DsdMode::DOP)
FormatDebug(alsa_output_domain, "DoP (DSD over PCM) enabled");
#endif

View File

@@ -787,7 +787,7 @@ OSXOutput::Open(AudioFormat &audio_format)
#ifdef ENABLE_DSD
if (dop && audio_format.format == SampleFormat::DSD) {
asbd.mBitsPerChannel = 24;
params.dop = true;
params.dsd_mode = PcmExport::DsdMode::DOP;
asbd.mSampleRate = params.CalcOutputSampleRate(audio_format.sample_rate);
asbd.mBytesPerPacket = 4 * audio_format.channels;
@@ -802,14 +802,14 @@ OSXOutput::Open(AudioFormat &audio_format)
#ifdef ENABLE_DSD
if(audio_format.format == SampleFormat::DSD && sample_rate != asbd.mSampleRate) { // fall back to PCM in case sample_rate cannot be synchronized
params.dop = false;
params.dsd_mode = PcmExport::DsdMode::NONE;
audio_format.format = SampleFormat::S32;
asbd.mBitsPerChannel = 32;
asbd.mBytesPerPacket = audio_format.GetFrameSize();
asbd.mSampleRate = params.CalcOutputSampleRate(audio_format.sample_rate);
asbd.mBytesPerFrame = asbd.mBytesPerPacket;
}
dop_enabled = params.dop;
dop_enabled = params.dsd_mode == PcmExport::DsdMode::DOP;
#endif
OSStatus status =