diff options
author | Max Kellermann <max@duempel.org> | 2014-08-23 13:57:57 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-23 13:57:57 +0200 |
commit | f2a75fbfc77b9f6d7118accb42391bef85f0dfcf (patch) | |
tree | 60ecf24511d2a1574769490897d0d338d1747676 /src | |
parent | b1fb09e18366040b5e17b100cd8469933acddbef (diff) | |
download | mpd-f2a75fbfc77b9f6d7118accb42391bef85f0dfcf.tar.gz mpd-f2a75fbfc77b9f6d7118accb42391bef85f0dfcf.tar.xz mpd-f2a75fbfc77b9f6d7118accb42391bef85f0dfcf.zip |
decoder/dsf: refactor the main decoder loop
Check for STOP before decoding the first chunk. This reduces the
command latency.
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/DsfDecoderPlugin.cxx | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/decoder/plugins/DsfDecoderPlugin.cxx b/src/decoder/plugins/DsfDecoderPlugin.cxx index 3b967fc14..2e8bc4f2a 100644 --- a/src/decoder/plugins/DsfDecoderPlugin.cxx +++ b/src/decoder/plugins/DsfDecoderPlugin.cxx @@ -254,7 +254,8 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is, { const size_t block_size = channels * DSF_BLOCK_SIZE; - for (offset_type i = 0; i < n_blocks;) { + auto cmd = decoder_get_command(decoder); + for (offset_type i = 0; i < n_blocks && cmd != DecoderCommand::STOP;) { /* worst-case buffer size */ uint8_t buffer[MAX_CHANNELS * DSF_BLOCK_SIZE]; if (!decoder_read_full(&decoder, is, buffer, block_size)) @@ -266,25 +267,12 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is, uint8_t interleaved_buffer[MAX_CHANNELS * DSF_BLOCK_SIZE]; InterleaveDsfBlock(interleaved_buffer, buffer, channels); - const auto cmd = decoder_data(decoder, is, - interleaved_buffer, block_size, - sample_rate / 1000); - switch (cmd) { - case DecoderCommand::NONE: - ++i; - 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, + interleaved_buffer, block_size, + sample_rate / 1000); + ++i; } + return true; } |