From 8e42467bd274fe4e0b15781c4d57e505185fced0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 12 Jul 2024 16:10:45 +0200 Subject: [PATCH] decoder/mpg123: relax mpg123_length() check in Scan() Do not fail the Scan() function completely if libmpg123 cannot determine the duration. --- src/decoder/plugins/Mpg123DecoderPlugin.cxx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/decoder/plugins/Mpg123DecoderPlugin.cxx b/src/decoder/plugins/Mpg123DecoderPlugin.cxx index bcce84b04..3ae5e86f8 100644 --- a/src/decoder/plugins/Mpg123DecoderPlugin.cxx +++ b/src/decoder/plugins/Mpg123DecoderPlugin.cxx @@ -390,20 +390,17 @@ Scan(mpg123_handle &handle, TagHandler &handler) noexcept return false; } - const off_t num_samples = mpg123_length(&handle); - if (num_samples <= 0) { - return false; - } - handler.OnAudioFormat(audio_format); /* ID3 tag support not yet implemented */ - const auto duration = - SongTime::FromScale(num_samples, - audio_format.sample_rate); + if (const off_t num_samples = mpg123_length(&handle); num_samples >= 0) { + const auto duration = + SongTime::FromScale(num_samples, + audio_format.sample_rate); + handler.OnDuration(duration); + } - handler.OnDuration(duration); return true; }