decoder/mpg123: relax mpg123_length() check in Scan()

Do not fail the Scan() function completely if libmpg123 cannot
determine the duration.
This commit is contained in:
Max Kellermann 2024-07-12 16:10:45 +02:00
parent e00e7802c8
commit 8e42467bd2
1 changed files with 6 additions and 9 deletions

View File

@ -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<uint64_t>(num_samples,
audio_format.sample_rate);
if (const off_t num_samples = mpg123_length(&handle); num_samples >= 0) {
const auto duration =
SongTime::FromScale<uint64_t>(num_samples,
audio_format.sample_rate);
handler.OnDuration(duration);
}
handler.OnDuration(duration);
return true;
}