From cfd51db2292aa9ff0b33d2a7ac50a78cafec6015 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 10 Nov 2016 11:45:17 +0100 Subject: CheckAudioFormat: migrate from class Error to C++ exceptions --- src/decoder/plugins/DsfDecoderPlugin.cxx | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'src/decoder/plugins/DsfDecoderPlugin.cxx') diff --git a/src/decoder/plugins/DsfDecoderPlugin.cxx b/src/decoder/plugins/DsfDecoderPlugin.cxx index 47d8d004d..8dce68a3a 100644 --- a/src/decoder/plugins/DsfDecoderPlugin.cxx +++ b/src/decoder/plugins/DsfDecoderPlugin.cxx @@ -33,7 +33,6 @@ #include "input/InputStream.hxx" #include "CheckAudioFormat.hxx" #include "util/bit_reverse.h" -#include "util/Error.hxx" #include "system/ByteOrder.hxx" #include "DsdLib.hxx" #include "tag/TagHandler.hxx" @@ -307,14 +306,10 @@ dsf_stream_decode(Decoder &decoder, InputStream &is) if (!dsf_read_metadata(&decoder, is, &metadata)) return; - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, metadata.sample_rate / 8, - SampleFormat::DSD, - metadata.channels, error)) { - LogError(error); - return; - } + auto audio_format = CheckAudioFormat(metadata.sample_rate / 8, + SampleFormat::DSD, + metadata.channels); + /* Calculate song time from DSD chunk size and sample frequency */ const auto n_blocks = metadata.n_blocks; auto songtime = SongTime::FromScale(n_blocks * DSF_BLOCK_SIZE, @@ -339,12 +334,9 @@ dsf_scan_stream(InputStream &is, if (!dsf_read_metadata(nullptr, is, &metadata)) return false; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, metadata.sample_rate / 8, - SampleFormat::DSD, - metadata.channels, IgnoreError())) - /* refuse to parse files which we cannot play anyway */ - return false; + auto audio_format = CheckAudioFormat(metadata.sample_rate / 8, + SampleFormat::DSD, + metadata.channels); /* calculate song time and add as tag */ const auto n_blocks = metadata.n_blocks; -- cgit v1.2.3