diff options
author | Max Kellermann <max@musicpd.org> | 2018-07-07 13:54:02 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-07-07 13:54:02 +0200 |
commit | 1245b4a49f98e990eda9b52427858ebd274530d1 (patch) | |
tree | dfff610bcd6ba4c707fa40bf13b8454abc859d9e /src/decoder | |
parent | d4ce6049c9c56294459ad66536518e95d7642be4 (diff) |
decoder/wavpack: merge duplicate code into Scan()
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/plugins/WavpackDecoderPlugin.cxx | 33 |
1 files 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; } |