Commit 952c7932 authored by Max Kellermann's avatar Max Kellermann

decoder/mad: subtract libmad decoder delay from LAME encoder padding

Apparently, libmad not only inserts 529 samples of silence at the beginning of the file, but also removes them at the end. This solves the last piece of https://github.com/MusicPlayerDaemon/MPD/issues/601 Closes https://github.com/MusicPlayerDaemon/MPD/issues/601
parent 3e3d8c7f
ver 0.21.12 (not yet released) ver 0.21.12 (not yet released)
* decoder * decoder
- mad: update bit rate after seeking - mad: update bit rate after seeking
- mad: fix several bugs preventing the plugin from decoding the last frame
- opus: ignore case in replay gain tag names - opus: ignore case in replay gain tag names
- opus, vorbis: decode the "end of stream" packet - opus, vorbis: decode the "end of stream" packet
* output * output
......
...@@ -749,9 +749,17 @@ MadDecoder::DecodeFirstFrame(Tag *tag) noexcept ...@@ -749,9 +749,17 @@ MadDecoder::DecodeFirstFrame(Tag *tag) noexcept
struct lame lame; struct lame lame;
if (parse_lame(&lame, &ptr, &bitlen)) { if (parse_lame(&lame, &ptr, &bitlen)) {
if (gapless_playback && input_stream.IsSeekable()) { if (gapless_playback && input_stream.IsSeekable()) {
/* libmad inserts 529 samples of
silence at the beginning and
removes those 529 samples at the
end */
drop_start_samples = lame.encoder_delay + drop_start_samples = lame.encoder_delay +
DECODERDELAY; DECODERDELAY;
drop_end_samples = lame.encoder_padding; drop_end_samples = lame.encoder_padding;
if (drop_end_samples > DECODERDELAY)
drop_end_samples -= DECODERDELAY;
else
drop_end_samples = 0;
} }
/* Album gain isn't currently used. See comment in /* Album gain isn't currently used. See comment in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment