diff options
author | Max Kellermann <max@musicpd.org> | 2016-11-10 11:45:17 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-11-10 12:55:08 +0100 |
commit | cfd51db2292aa9ff0b33d2a7ac50a78cafec6015 (patch) | |
tree | 4026d81758898f259622d5cce49f8b052237eaff | |
parent | 12f11c97ae9e5b1b6367e4a5c49713fdd4984b89 (diff) |
CheckAudioFormat: migrate from class Error to C++ exceptions
22 files changed, 98 insertions, 212 deletions
diff --git a/src/CheckAudioFormat.cxx b/src/CheckAudioFormat.cxx index 5146f02ea..a6d0615d1 100644 --- a/src/CheckAudioFormat.cxx +++ b/src/CheckAudioFormat.cxx @@ -20,61 +20,43 @@ #include "config.h" #include "CheckAudioFormat.hxx" #include "AudioFormat.hxx" -#include "util/Error.hxx" -#include "util/Domain.hxx" +#include "util/RuntimeError.hxx" -#include <assert.h> +#include <stdexcept> -const Domain audio_format_domain("audio_format"); +#include <assert.h> -bool -audio_check_sample_rate(unsigned long sample_rate, Error &error) +void +CheckSampleRate(unsigned long sample_rate) { - if (!audio_valid_sample_rate(sample_rate)) { - error.Format(audio_format_domain, - "Invalid sample rate: %lu", sample_rate); - return false; - } - - return true; + if (!audio_valid_sample_rate(sample_rate)) + throw FormatRuntimeError("Invalid sample rate: %lu", + sample_rate); } -bool -audio_check_sample_format(SampleFormat sample_format, Error &error) +void +CheckSampleFormat(SampleFormat sample_format) { - if (!audio_valid_sample_format(sample_format)) { - error.Format(audio_format_domain, - "Invalid sample format: %u", - unsigned(sample_format)); - return false; - } - - return true; + if (!audio_valid_sample_format(sample_format)) + throw FormatRuntimeError("Invalid sample format: %u", + unsigned(sample_format)); } -bool -audio_check_channel_count(unsigned channels, Error &error) +void +CheckChannelCount(unsigned channels) { - if (!audio_valid_channel_count(channels)) { - error.Format(audio_format_domain, - "Invalid channel count: %u", channels); - return false; - } - - return true; + if (!audio_valid_channel_count(channels)) + throw FormatRuntimeError("Invalid channel count: %u", + channels); } -bool -audio_format_init_checked(AudioFormat &af, unsigned long sample_rate, - SampleFormat sample_format, unsigned channels, - Error &error) +AudioFormat +CheckAudioFormat(unsigned long sample_rate, + SampleFormat sample_format, unsigned channels) { - if (audio_check_sample_rate(sample_rate, error) && - audio_check_sample_format(sample_format, error) && - audio_check_channel_count(channels, error)) { - af = AudioFormat(sample_rate, sample_format, channels); - assert(af.IsValid()); - return true; - } else - return false; + CheckSampleRate(sample_rate); + CheckSampleFormat(sample_format); + CheckChannelCount(channels); + + return AudioFormat(sample_rate, sample_format, channels); } diff --git a/src/CheckAudioFormat.hxx b/src/CheckAudioFormat.hxx index b155b0760..05cd5ad08 100644 --- a/src/CheckAudioFormat.hxx +++ b/src/CheckAudioFormat.hxx @@ -22,25 +22,23 @@ #include "AudioFormat.hxx" -class Error; +void +CheckSampleRate(unsigned long sample_rate); -extern const class Domain audio_format_domain; +void +CheckSampleFormat(SampleFormat sample_format); -bool -audio_check_sample_rate(unsigned long sample_rate, Error &error); - -bool -audio_check_sample_format(SampleFormat sample_format, Error &error); - -bool -audio_check_channel_count(unsigned sample_format, Error &error); +void +CheckChannelCount(unsigned sample_format); /** - * Wrapper for audio_format_init(), which checks all attributes. + * Check #AudioFormat attributes and construct an #AudioFormat + * instance. + * + * Throws #std::runtime_error on error. */ -bool -audio_format_init_checked(AudioFormat &af, unsigned long sample_rate, - SampleFormat sample_format, unsigned channels, - Error &error); +AudioFormat +CheckAudioFormat(unsigned long sample_rate, + SampleFormat sample_format, unsigned channels); #endif diff --git a/src/decoder/plugins/AdPlugDecoderPlugin.cxx b/src/decoder/plugins/AdPlugDecoderPlugin.cxx index fe3e55410..703fded55 100644 --- a/src/decoder/plugins/AdPlugDecoderPlugin.cxx +++ b/src/decoder/plugins/AdPlugDecoderPlugin.cxx @@ -23,7 +23,6 @@ #include "../DecoderAPI.hxx" #include "CheckAudioFormat.hxx" #include "fs/Path.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "util/Macros.hxx" #include "Log.hxx" @@ -43,13 +42,8 @@ adplug_init(const ConfigBlock &block) FormatDebug(adplug_domain, "adplug %s", CAdPlug::get_version().c_str()); - Error error; - sample_rate = block.GetBlockValue("sample_rate", 48000u); - if (!audio_check_sample_rate(sample_rate, error)) { - LogError(error); - return false; - } + CheckSampleRate(sample_rate); return true; } diff --git a/src/decoder/plugins/AudiofileDecoderPlugin.cxx b/src/decoder/plugins/AudiofileDecoderPlugin.cxx index b1b97b272..62a81b071 100644 --- a/src/decoder/plugins/AudiofileDecoderPlugin.cxx +++ b/src/decoder/plugins/AudiofileDecoderPlugin.cxx @@ -24,7 +24,6 @@ #include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" #include "util/ScopeExit.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -198,16 +197,10 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is) AtScopeExit(fh) { afCloseFile(fh); }; - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, - afGetRate(fh, AF_DEFAULT_TRACK), - audiofile_setup_sample_format(fh), - afGetVirtualChannels(fh, AF_DEFAULT_TRACK), - error)) { - LogError(error); - return; - } + const auto audio_format = + CheckAudioFormat(afGetRate(fh, AF_DEFAULT_TRACK), + audiofile_setup_sample_format(fh), + afGetVirtualChannels(fh, AF_DEFAULT_TRACK)); const auto total_time = audiofile_get_duration(fh); diff --git a/src/decoder/plugins/DsdiffDecoderPlugin.cxx b/src/decoder/plugins/DsdiffDecoderPlugin.cxx index 6653f2053..78fda3a12 100644 --- a/src/decoder/plugins/DsdiffDecoderPlugin.cxx +++ b/src/decoder/plugins/DsdiffDecoderPlugin.cxx @@ -32,7 +32,6 @@ #include "input/InputStream.hxx" #include "CheckAudioFormat.hxx" #include "util/bit_reverse.h" -#include "util/Error.hxx" #include "system/ByteOrder.hxx" #include "tag/TagHandler.hxx" #include "DsdLib.hxx" @@ -426,14 +425,9 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is) if (!dsdiff_read_metadata(&decoder, is, &metadata, &chunk_header)) 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 */ offset_type chunk_size = metadata.chunk_size; @@ -466,12 +460,9 @@ dsdiff_scan_stream(InputStream &is, if (!dsdiff_read_metadata(nullptr, is, &metadata, &chunk_header)) 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 */ uint64_t n_frames = metadata.chunk_size / audio_format.channels; 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<uint64_t>(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; diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx index 79e3755c8..bc12a1509 100644 --- a/src/decoder/plugins/FaadDecoderPlugin.cxx +++ b/src/decoder/plugins/FaadDecoderPlugin.cxx @@ -273,8 +273,9 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer, buffer.Consume(nbytes); - return audio_format_init_checked(audio_format, sample_rate, - SampleFormat::S16, channels, error); + audio_format = CheckAudioFormat(sample_rate, SampleFormat::S16, + channels); + return true; } /** diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 3df5053fb..3fd8e4d4d 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -40,7 +40,6 @@ #include "CheckAudioFormat.hxx" #include "util/ScopeExit.hxx" #include "util/ConstBuffer.hxx" -#include "util/Error.hxx" #include "LogV.hxx" extern "C" { @@ -666,15 +665,9 @@ FfmpegDecode(Decoder &decoder, InputStream &input, return; } - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, - codec_params.sample_rate, - sample_format, - codec_params.channels, error)) { - LogError(error); - return; - } + const auto audio_format = CheckAudioFormat(codec_params.sample_rate, + sample_format, + codec_params.channels); /* the audio format must be read from AVCodecContext by now, because avcodec_open() has been demonstrated to fill bogus diff --git a/src/decoder/plugins/FlacPcm.cxx b/src/decoder/plugins/FlacPcm.cxx index f1e3e3a37..82d2dadf4 100644 --- a/src/decoder/plugins/FlacPcm.cxx +++ b/src/decoder/plugins/FlacPcm.cxx @@ -58,12 +58,7 @@ FlacPcmImport::Open(unsigned sample_rate, unsigned bits_per_sample, return false; } - if (!audio_format_init_checked(audio_format, - sample_rate, - sample_format, - channels, error)) - return false; - + audio_format = CheckAudioFormat(sample_rate, sample_format, channels); return true; } diff --git a/src/decoder/plugins/FlacPcm.hxx b/src/decoder/plugins/FlacPcm.hxx index d40d08362..9c6641025 100644 --- a/src/decoder/plugins/FlacPcm.hxx +++ b/src/decoder/plugins/FlacPcm.hxx @@ -39,9 +39,6 @@ class FlacPcmImport { AudioFormat audio_format; public: - /** - * @return false on error - */ bool Open(unsigned sample_rate, unsigned bits_per_sample, unsigned channels, Error &error); diff --git a/src/decoder/plugins/FluidsynthDecoderPlugin.cxx b/src/decoder/plugins/FluidsynthDecoderPlugin.cxx index cfe9cab63..c40beff8a 100644 --- a/src/decoder/plugins/FluidsynthDecoderPlugin.cxx +++ b/src/decoder/plugins/FluidsynthDecoderPlugin.cxx @@ -22,7 +22,6 @@ #include "../DecoderAPI.hxx" #include "CheckAudioFormat.hxx" #include "fs/Path.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "util/Macros.hxx" #include "Log.hxx" @@ -75,13 +74,8 @@ fluidsynth_mpd_log_function(int level, char *message, gcc_unused void *data) static bool fluidsynth_init(const ConfigBlock &block) { - Error error; - sample_rate = block.GetBlockValue("sample_rate", 48000u); - if (!audio_check_sample_rate(sample_rate, error)) { - LogError(error); - return false; - } + CheckSampleRate(sample_rate); soundfont_path = block.GetBlockValue("soundfont", "/usr/share/sounds/sf2/FluidR3_GM.sf2"); diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index 422e843be..e47447c9d 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -29,7 +29,6 @@ #include "util/FormatString.hxx" #include "util/AllocatedString.hxx" #include "util/UriUtil.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -168,14 +167,9 @@ gme_file_decode(Decoder &decoder, Path path_fs) /* initialize the MPD decoder */ - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, GME_SAMPLE_RATE, - SampleFormat::S16, GME_CHANNELS, - error)) { - LogError(error); - return; - } + const auto audio_format = CheckAudioFormat(GME_SAMPLE_RATE, + SampleFormat::S16, + GME_CHANNELS); decoder_initialized(decoder, audio_format, true, song_len); diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 936e38822..cb34aecea 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -29,7 +29,6 @@ #include "tag/MixRamp.hxx" #include "CheckAudioFormat.hxx" #include "util/StringCompare.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -1051,19 +1050,10 @@ mp3_decode(Decoder &decoder, InputStream &input_stream) data.AllocateBuffers(); - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, - data.frame.header.samplerate, - SampleFormat::S24_P32, - MAD_NCHANNELS(&data.frame.header), - error)) { - LogError(error); - delete tag; - return; - } - - decoder_initialized(decoder, audio_format, + decoder_initialized(decoder, + CheckAudioFormat(data.frame.header.samplerate, + SampleFormat::S24_P32, + MAD_NCHANNELS(&data.frame.header)), input_stream.IsSeekable(), data.total_time); diff --git a/src/decoder/plugins/MpcdecDecoderPlugin.cxx b/src/decoder/plugins/MpcdecDecoderPlugin.cxx index ee14fcea2..3becac779 100644 --- a/src/decoder/plugins/MpcdecDecoderPlugin.cxx +++ b/src/decoder/plugins/MpcdecDecoderPlugin.cxx @@ -24,7 +24,6 @@ #include "CheckAudioFormat.hxx" #include "pcm/Traits.hxx" #include "tag/TagHandler.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "util/Macros.hxx" #include "util/Clamp.hxx" @@ -162,15 +161,9 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is) mpc_streaminfo info; mpc_demux_get_info(demux, &info); - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, info.sample_freq, - mpcdec_sample_format, - info.channels, error)) { - LogError(error); - mpc_demux_exit(demux); - return; - } + auto audio_format = CheckAudioFormat(info.sample_freq, + mpcdec_sample_format, + info.channels); ReplayGainInfo rgi; rgi.Clear(); diff --git a/src/decoder/plugins/Mpg123DecoderPlugin.cxx b/src/decoder/plugins/Mpg123DecoderPlugin.cxx index 1b62fc43e..942398b20 100644 --- a/src/decoder/plugins/Mpg123DecoderPlugin.cxx +++ b/src/decoder/plugins/Mpg123DecoderPlugin.cxx @@ -26,7 +26,6 @@ #include "tag/ReplayGain.hxx" #include "tag/MixRamp.hxx" #include "fs/Path.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "util/StringView.hxx" #include "Log.hxx" @@ -95,13 +94,7 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs, return false; } - Error error2; - if (!audio_format_init_checked(audio_format, rate, SampleFormat::S16, - channels, error2)) { - LogError(error2); - return false; - } - + audio_format = CheckAudioFormat(rate, SampleFormat::S16, channels); return true; } diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx index 17dd58d48..6e60fb3cd 100644 --- a/src/decoder/plugins/OpusDecoderPlugin.cxx +++ b/src/decoder/plugins/OpusDecoderPlugin.cxx @@ -32,7 +32,6 @@ #include "tag/TagHandler.hxx" #include "tag/TagBuilder.hxx" #include "input/InputStream.hxx" -#include "util/Error.hxx" #include "util/RuntimeError.hxx" #include "Log.hxx" diff --git a/src/decoder/plugins/PcmDecoderPlugin.cxx b/src/decoder/plugins/PcmDecoderPlugin.cxx index 3a826b086..bc39b1324 100644 --- a/src/decoder/plugins/PcmDecoderPlugin.cxx +++ b/src/decoder/plugins/PcmDecoderPlugin.cxx @@ -23,7 +23,7 @@ #include "CheckAudioFormat.hxx" #include "input/InputStream.hxx" #include "system/ByteOrder.hxx" -#include "util/Error.hxx" +#include "util/Domain.hxx" #include "util/ByteReverse.hxx" #include "util/NumberParser.hxx" #include "util/MimeType.hxx" @@ -33,6 +33,8 @@ #include <string.h> +static constexpr Domain pcm_decoder_domain("pcm_decoder"); + static void pcm_stream_decode(Decoder &decoder, InputStream &is) { @@ -62,7 +64,6 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) { const auto mime_parameters = ParseMimeTypeParameters(mime); - Error error; /* MIME type parameters according to RFC 2586 */ auto i = mime_parameters.find("rate"); @@ -71,14 +72,16 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) char *endptr; unsigned value = ParseUnsigned(s, &endptr); if (endptr == s || *endptr != 0) { - FormatWarning(audio_format_domain, + FormatWarning(pcm_decoder_domain, "Failed to parse sample rate: %s", s); return; } - if (!audio_check_sample_rate(value, error)) { - LogError(error); + try { + CheckSampleRate(value); + } catch (const std::runtime_error &e) { + LogError(e); return; } @@ -91,14 +94,16 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) char *endptr; unsigned value = ParseUnsigned(s, &endptr); if (endptr == s || *endptr != 0) { - FormatWarning(audio_format_domain, + FormatWarning(pcm_decoder_domain, "Failed to parse sample rate: %s", s); return; } - if (!audio_check_channel_count(value, error)) { - LogError(error); + try { + CheckChannelCount(value); + } catch (const std::runtime_error &e) { + LogError(e); return; } @@ -107,7 +112,7 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) } if (audio_format.sample_rate == 0) { - FormatWarning(audio_format_domain, + FormatWarning(pcm_decoder_domain, "Missing 'rate' parameter: %s", mime); return; diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index 6a49f2234..8cc99cabd 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -27,7 +27,6 @@ #include "util/FormatString.hxx" #include "util/AllocatedString.hxx" #include "util/Domain.hxx" -#include "util/Error.hxx" #include "system/ByteOrder.hxx" #include "system/FatalError.hxx" #include "Log.hxx" diff --git a/src/decoder/plugins/SndfileDecoderPlugin.cxx b/src/decoder/plugins/SndfileDecoderPlugin.cxx index ec45270fb..051166c1c 100644 --- a/src/decoder/plugins/SndfileDecoderPlugin.cxx +++ b/src/decoder/plugins/SndfileDecoderPlugin.cxx @@ -23,7 +23,6 @@ #include "input/InputStream.hxx" #include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -201,14 +200,10 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is) return; } - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, info.samplerate, - sndfile_sample_format(info), - info.channels, error)) { - LogError(error); - return; - } + const auto audio_format = + CheckAudioFormat(info.samplerate, + sndfile_sample_format(info), + info.channels); decoder_initialized(decoder, audio_format, info.seekable, sndfile_duration(info)); diff --git a/src/decoder/plugins/VorbisDecoderPlugin.cxx b/src/decoder/plugins/VorbisDecoderPlugin.cxx index 178303df8..e63e76039 100644 --- a/src/decoder/plugins/VorbisDecoderPlugin.cxx +++ b/src/decoder/plugins/VorbisDecoderPlugin.cxx @@ -29,7 +29,6 @@ #include "input/Reader.hxx" #include "OggCodec.hxx" #include "pcm/Interleave.hxx" -#include "util/Error.hxx" #include "util/Macros.hxx" #include "util/ScopeExit.hxx" #include "CheckAudioFormat.hxx" @@ -166,10 +165,7 @@ VorbisDecoder::SubmitInit() { assert(!dsp_initialized); - Error error; - if (!audio_format_init_checked(audio_format, vi.rate, sample_format, - vi.channels, error)) - throw std::runtime_error(error.GetMessage()); + audio_format = CheckAudioFormat(vi.rate, sample_format, vi.channels); frame_size = audio_format.GetFrameSize(); diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index 7dd3ed7b0..1835525b2 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -25,7 +25,6 @@ #include "tag/TagHandler.hxx" #include "tag/ApeTag.hxx" #include "fs/Path.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "util/Macros.hxx" #include "util/Alloc.hxx" @@ -149,15 +148,9 @@ wavpack_decode(Decoder &decoder, WavpackContext *wpc, bool can_seek) wavpack_bits_to_sample_format(is_float, WavpackGetBytesPerSample(wpc)); - Error error; - AudioFormat audio_format; - if (!audio_format_init_checked(audio_format, - WavpackGetSampleRate(wpc), - sample_format, - WavpackGetNumChannels(wpc), error)) { - LogError(error); - return; - } + auto audio_format = CheckAudioFormat(WavpackGetSampleRate(wpc), + sample_format, + WavpackGetNumChannels(wpc)); const format_samples_t format_samples = is_float ? format_samples_float diff --git a/src/decoder/plugins/WildmidiDecoderPlugin.cxx b/src/decoder/plugins/WildmidiDecoderPlugin.cxx index ed879ae9f..d699c4ea6 100644 --- a/src/decoder/plugins/WildmidiDecoderPlugin.cxx +++ b/src/decoder/plugins/WildmidiDecoderPlugin.cxx @@ -21,7 +21,6 @@ #include "WildmidiDecoderPlugin.hxx" #include "../DecoderAPI.hxx" #include "tag/TagHandler.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "fs/AllocatedPath.hxx" #include "fs/FileSystem.hxx" |