From 6fe06cad98360e872f06a6027f038d1949574e94 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 23 Aug 2014 13:44:53 +0200 Subject: decoder/dsf: count the blocks, not the remaining bytes Prepare refactoring the whole plugin to use blocks instead of bytes. A block is the smallest addressable unit, and it will simplify the seeking code. --- src/decoder/plugins/DsfDecoderPlugin.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/decoder/plugins/DsfDecoderPlugin.cxx b/src/decoder/plugins/DsfDecoderPlugin.cxx index 9791c4fda..81ed07315 100644 --- a/src/decoder/plugins/DsfDecoderPlugin.cxx +++ b/src/decoder/plugins/DsfDecoderPlugin.cxx @@ -255,9 +255,9 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is, const size_t block_size = channels * DSF_BLOCK_SIZE; - while (chunk_size >= block_size) { - chunk_size -= block_size; + const offset_type n_blocks = chunk_size / block_size; + for (offset_type i = 0; i < n_blocks;) { if (!decoder_read_full(&decoder, is, buffer, block_size)) return false; @@ -272,6 +272,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is, sample_rate / 1000); switch (cmd) { case DecoderCommand::NONE: + ++i; break; case DecoderCommand::START: -- cgit v1.2.3