aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/plugins/DsfDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-21 13:05:35 +0200
committerMax Kellermann <max@duempel.org>2014-08-21 13:05:35 +0200
commit57cbcdf2ecc8ff2a5b093f01028ea887f088a8aa (patch)
tree5539770870b77fe62c9f38950d1a18377140c729 /src/decoder/plugins/DsfDecoderPlugin.cxx
parent455fd180b124844f567e25ba8e8884be9b6fa145 (diff)
downloadmpd-57cbcdf2ecc8ff2a5b093f01028ea887f088a8aa.tar.gz
mpd-57cbcdf2ecc8ff2a5b093f01028ea887f088a8aa.tar.xz
mpd-57cbcdf2ecc8ff2a5b093f01028ea887f088a8aa.zip
decoder/dsf: make the "scratch" buffer local
This allows the compiler to discard buffer contents between two function calls.
Diffstat (limited to 'src/decoder/plugins/DsfDecoderPlugin.cxx')
-rw-r--r--src/decoder/plugins/DsfDecoderPlugin.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/decoder/plugins/DsfDecoderPlugin.cxx b/src/decoder/plugins/DsfDecoderPlugin.cxx
index b4f90b15b..585819f52 100644
--- a/src/decoder/plugins/DsfDecoderPlugin.cxx
+++ b/src/decoder/plugins/DsfDecoderPlugin.cxx
@@ -193,8 +193,11 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
* order.
*/
static void
-dsf_to_pcm_order(uint8_t *dest, uint8_t *scratch, size_t nrbytes)
+dsf_to_pcm_order(uint8_t *dest, size_t nrbytes)
{
+ uint8_t scratch[8192];
+ assert(nrbytes <= sizeof(scratch));
+
for (unsigned i = 0, j = 0; i < (unsigned)nrbytes; i += 2) {
scratch[i] = *(dest+j);
j++;
@@ -222,10 +225,6 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
{
uint8_t buffer[8192];
- /* scratch buffer for DSF samples to convert to the needed
- normal left/right regime of samples */
- uint8_t dsf_scratch_buffer[8192];
-
const size_t sample_size = sizeof(buffer[0]);
const size_t frame_size = channels * sample_size;
const unsigned buffer_frames = sizeof(buffer) / frame_size;
@@ -250,7 +249,7 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
if (bitreverse)
bit_reverse_buffer(buffer, buffer + nbytes);
- dsf_to_pcm_order(buffer, dsf_scratch_buffer, nbytes);
+ dsf_to_pcm_order(buffer, nbytes);
const auto cmd = decoder_data(decoder, is, buffer, nbytes,
sample_rate / 1000);