From 1245b4a49f98e990eda9b52427858ebd274530d1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 7 Jul 2018 13:54:02 +0200 Subject: [PATCH] decoder/wavpack: merge duplicate code into Scan() --- src/decoder/plugins/WavpackDecoderPlugin.cxx | 33 +++++++++----------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index fc3a9df49..85e0417f3 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -580,6 +580,19 @@ wavpack_filedecode(DecoderClient &client, Path path_fs) wavpack_decode(client, wpc, true); } +static void +Scan(WavpackContext *wpc,TagHandler &handler) noexcept +{ + try { + handler.OnAudioFormat(CheckAudioFormat(wpc)); + } catch (...) { + } + + const auto duration = GetDuration(wpc); + if (!duration.IsNegative()) + handler.OnDuration(SongTime(duration)); +} + /* * Reads metainfo from the specified file. */ @@ -598,15 +611,7 @@ wavpack_scan_file(Path path_fs, TagHandler &handler) noexcept WavpackCloseFile(wpc); }; - try { - handler.OnAudioFormat(CheckAudioFormat(wpc)); - } catch (...) { - } - - const auto duration = GetDuration(wpc); - if (!duration.IsNegative()) - handler.OnDuration(SongTime(duration)); - + Scan(wpc, handler); return true; } @@ -627,15 +632,7 @@ wavpack_scan_stream(InputStream &is, TagHandler &handler) noexcept WavpackCloseFile(wpc); }; - try { - handler.OnAudioFormat(CheckAudioFormat(wpc)); - } catch (...) { - } - - const auto duration = GetDuration(wpc); - if (!duration.IsNegative()) - handler.OnDuration(SongTime(duration)); - + Scan(wpc, handler); return true; }