From 4f56fdc3970047943571147d4fa320db6e900840 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 3 Aug 2019 08:09:45 +0200 Subject: decoder/mad: make "current_frame" zero-based Increment "current_frame" after processing the frame. --- src/decoder/plugins/MadDecoderPlugin.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 3fb38e0b9..7b3675e37 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -863,7 +863,7 @@ MadDecoder::SyncAndSend() noexcept drop_start_frames--; return DecoderCommand::NONE; } else if ((drop_end_frames > 0) && - (current_frame == (max_frames + 1 - drop_end_frames))) { + current_frame == max_frames - drop_end_frames) { /* stop decoding, effectively dropping all remaining frames */ return DecoderCommand::STOP; @@ -877,7 +877,7 @@ MadDecoder::SyncAndSend() noexcept unsigned pcm_length = synth.pcm.length; if (drop_end_samples && - (current_frame == max_frames - drop_end_frames)) { + current_frame == max_frames - drop_end_frames - 1) { if (drop_end_samples >= pcm_length) pcm_length = 0; else @@ -889,7 +889,7 @@ MadDecoder::SyncAndSend() noexcept return cmd; if (drop_end_samples && - (current_frame == max_frames - drop_end_frames)) + current_frame == max_frames - drop_end_frames - 1) /* stop decoding, effectively dropping * all remaining samples */ return DecoderCommand::STOP; @@ -900,20 +900,21 @@ MadDecoder::SyncAndSend() noexcept inline bool MadDecoder::Read() noexcept { - UpdateTimerNextFrame(); - switch (mute_frame) { DecoderCommand cmd; case MadDecoderMuteFrame::SKIP: mute_frame = MadDecoderMuteFrame::NONE; + UpdateTimerNextFrame(); break; case MadDecoderMuteFrame::SEEK: if (elapsed_time >= seek_time) mute_frame = MadDecoderMuteFrame::NONE; + UpdateTimerNextFrame(); break; case MadDecoderMuteFrame::NONE: cmd = SyncAndSend(); + UpdateTimerNextFrame(); if (cmd == DecoderCommand::SEEK) { assert(input_stream.IsSeekable()); -- cgit v1.2.3