aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/plugins/DsdiffDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-23 15:25:40 +0200
committerMax Kellermann <max@duempel.org>2014-08-23 15:25:40 +0200
commit6d7eaba845e3b1896a5b57391482a3326a6f26bd (patch)
tree08d98ca3db36104c0defe24a8cbcac199f3286e9 /src/decoder/plugins/DsdiffDecoderPlugin.cxx
parent4259b17b9123d9fdb0ec0133baf7de2722f799b2 (diff)
downloadmpd-6d7eaba845e3b1896a5b57391482a3326a6f26bd.tar.gz
mpd-6d7eaba845e3b1896a5b57391482a3326a6f26bd.tar.xz
mpd-6d7eaba845e3b1896a5b57391482a3326a6f26bd.zip
decoder/dsdiff: refactor the main decoder loop
Check for STOP before decoding the first chunk. This reduces the command latency.
Diffstat (limited to 'src/decoder/plugins/DsdiffDecoderPlugin.cxx')
-rw-r--r--src/decoder/plugins/DsdiffDecoderPlugin.cxx21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/decoder/plugins/DsdiffDecoderPlugin.cxx b/src/decoder/plugins/DsdiffDecoderPlugin.cxx
index c7495fe89..de72a0644 100644
--- a/src/decoder/plugins/DsdiffDecoderPlugin.cxx
+++ b/src/decoder/plugins/DsdiffDecoderPlugin.cxx
@@ -365,8 +365,9 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
const unsigned buffer_frames = sizeof(buffer) / frame_size;
const size_t buffer_size = buffer_frames * frame_size;
+ auto cmd = decoder_get_command(decoder);
for (offset_type remaining_bytes = total_bytes;
- remaining_bytes >= frame_size;) {
+ remaining_bytes >= frame_size && cmd != DecoderCommand::STOP;) {
/* see how much aligned data from the remaining chunk
fits into the local buffer */
size_t now_size = buffer_size;
@@ -384,22 +385,8 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
if (lsbitfirst)
bit_reverse_buffer(buffer, buffer + nbytes);
- const auto cmd = decoder_data(decoder, is, buffer, nbytes,
- sample_rate / 1000);
- switch (cmd) {
- case DecoderCommand::NONE:
- break;
-
- case DecoderCommand::START:
- case DecoderCommand::STOP:
- return false;
-
- case DecoderCommand::SEEK:
-
- /* Not implemented yet */
- decoder_seek_error(decoder);
- break;
- }
+ cmd = decoder_data(decoder, is, buffer, nbytes,
+ sample_rate / 1000);
}
return true;