diff options
author | Max Kellermann <max@duempel.org> | 2014-08-23 15:21:08 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-23 15:21:08 +0200 |
commit | 4259b17b9123d9fdb0ec0133baf7de2722f799b2 (patch) | |
tree | c97b19bd4de19958a54220543f8fb4bb45759282 /src | |
parent | 828ea700e828f337af86a709260792caaf0ec718 (diff) | |
download | mpd-4259b17b9123d9fdb0ec0133baf7de2722f799b2.tar.gz mpd-4259b17b9123d9fdb0ec0133baf7de2722f799b2.tar.xz mpd-4259b17b9123d9fdb0ec0133baf7de2722f799b2.zip |
decoder/dsdiff: add local variable "remaining_bytes"
Remember the chunk's total size.
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/DsdiffDecoderPlugin.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/decoder/plugins/DsdiffDecoderPlugin.cxx b/src/decoder/plugins/DsdiffDecoderPlugin.cxx index b5584d1fd..c7495fe89 100644 --- a/src/decoder/plugins/DsdiffDecoderPlugin.cxx +++ b/src/decoder/plugins/DsdiffDecoderPlugin.cxx @@ -356,7 +356,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end) static bool dsdiff_decode_chunk(Decoder &decoder, InputStream &is, unsigned channels, unsigned sample_rate, - offset_type chunk_size) + const offset_type total_bytes) { uint8_t buffer[8192]; @@ -365,12 +365,13 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is, const unsigned buffer_frames = sizeof(buffer) / frame_size; const size_t buffer_size = buffer_frames * frame_size; - while (chunk_size >= frame_size) { + for (offset_type remaining_bytes = total_bytes; + remaining_bytes >= frame_size;) { /* see how much aligned data from the remaining chunk fits into the local buffer */ size_t now_size = buffer_size; - if (chunk_size < (offset_type)now_size) { - unsigned now_frames = chunk_size / frame_size; + if (remaining_bytes < (offset_type)now_size) { + unsigned now_frames = remaining_bytes / frame_size; now_size = now_frames * frame_size; } @@ -378,7 +379,7 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is, return false; const size_t nbytes = now_size; - chunk_size -= nbytes; + remaining_bytes -= nbytes; if (lsbitfirst) bit_reverse_buffer(buffer, buffer + nbytes); |