diff options
author | Max Kellermann <max@musicpd.org> | 2019-08-03 08:09:45 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-08-03 08:24:25 +0200 |
commit | 4f56fdc3970047943571147d4fa320db6e900840 (patch) | |
tree | 641fa75c5cabfcdfdafc6bc6425236273b3ab429 /src/decoder/plugins/MadDecoderPlugin.cxx | |
parent | c87d6825ec0707fcfbc7a5b3fae971d7db35cf4d (diff) |
decoder/mad: make "current_frame" zero-based
Increment "current_frame" after processing the frame.
Diffstat (limited to 'src/decoder/plugins/MadDecoderPlugin.cxx')
-rw-r--r-- | src/decoder/plugins/MadDecoderPlugin.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
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()); |