From 0d0569b9afcf549045625e64f747a3c18b0a1f0a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 7 Jul 2018 13:09:23 +0200 Subject: [PATCH] decoder/mad: merge mad_decoder_total_file_time() into mad_decoder_scan_stream() --- src/decoder/plugins/MadDecoderPlugin.cxx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index c8dd1fe38..dcc6765c0 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -831,16 +831,6 @@ MadDecoder::~MadDecoder() delete[] times; } -/* this is primarily used for getting total time for tags */ -static std::pair -mad_decoder_total_file_time(InputStream &is) -{ - MadDecoder data(nullptr, is); - return data.DecodeFirstFrame(nullptr) - ? std::make_pair(true, data.total_time) - : std::make_pair(false, SignedSongTime::Negative()); -} - long MadDecoder::TimeToFrame(SongTime t) const noexcept { @@ -1064,12 +1054,12 @@ mp3_decode(DecoderClient &client, InputStream &input_stream) static bool mad_decoder_scan_stream(InputStream &is, TagHandler &handler) noexcept { - const auto result = mad_decoder_total_file_time(is); - if (!result.first) + MadDecoder data(nullptr, is); + if (!data.DecodeFirstFrame(nullptr)) return false; - if (!result.second.IsNegative()) - handler.OnDuration(SongTime(result.second)); + if (!data.total_time.IsNegative()) + handler.OnDuration(SongTime(data.total_time)); return true; }