decoder/mpg123: report unknown duration if mpg123_length()<0

Closes https://github.com/MusicPlayerDaemon/MPD/issues/2058
This commit is contained in:
Max Kellermann 2024-07-12 16:09:28 +02:00
parent 55d0bbade2
commit e00e7802c8

View File

@ -248,6 +248,8 @@ static SignedSongTime
GetDuration(mpg123_handle &handle, const AudioFormat &audio_format) noexcept GetDuration(mpg123_handle &handle, const AudioFormat &audio_format) noexcept
{ {
const off_t num_samples = mpg123_length(&handle); const off_t num_samples = mpg123_length(&handle);
if (num_samples < 0)
return SignedSongTime::Negative();
return SongTime::FromScale<uint64_t>(num_samples, return SongTime::FromScale<uint64_t>(num_samples,
audio_format.sample_rate); audio_format.sample_rate);