Skip to content

Commit

Permalink
decoder/mpg123: relax mpg123_length() check in Scan()
Browse files Browse the repository at this point in the history
Do not fail the Scan() function completely if libmpg123 cannot
determine the duration.
  • Loading branch information
MaxKellermann committed Jul 12, 2024
1 parent e00e780 commit 8e42467
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/decoder/plugins/Mpg123DecoderPlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8e42467

Please sign in to comment.