aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/DsfDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-28 23:01:13 +0100
committerMax Kellermann <max@duempel.org>2013-10-28 23:47:25 +0100
commit4728735acf20fba24d0d03ab431160e250325869 (patch)
treee1bf60cf4f3fc37b149318d7c774ce3f13b94a16 /src/decoder/DsfDecoderPlugin.cxx
parent9dcbd005f0087c5644d86db4eb1b24cc0c39d132 (diff)
downloadmpd-4728735acf20fba24d0d03ab431160e250325869.tar.gz
mpd-4728735acf20fba24d0d03ab431160e250325869.tar.xz
mpd-4728735acf20fba24d0d03ab431160e250325869.zip
decoder/dsf: don't play junk at the end of the "data" chunk
Diffstat (limited to 'src/decoder/DsfDecoderPlugin.cxx')
-rw-r--r--src/decoder/DsfDecoderPlugin.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx
index a7e2f3d1e..7f47074ee 100644
--- a/src/decoder/DsfDecoderPlugin.cxx
+++ b/src/decoder/DsfDecoderPlugin.cxx
@@ -156,12 +156,20 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
data_size -= sizeof(data_chunk);
- metadata->chunk_size = data_size;
/* data_size cannot be bigger or equal to total file size */
const uint64_t size = (uint64_t)is.GetSize();
if (data_size >= size)
return false;
+ /* use the sample count from the DSF header as the upper
+ bound, because some DSF files contain junk at the end of
+ the "data" chunk */
+ const uint64_t samplecnt = dsf_fmt_chunk.scnt.Read();
+ const uint64_t playable_size = samplecnt * 2 / 8;
+ if (data_size > playable_size)
+ data_size = playable_size;
+
+ metadata->chunk_size = data_size;
metadata->channels = (unsigned) dsf_fmt_chunk.channelnum;
metadata->sample_rate = samplefreq;
#ifdef HAVE_ID3TAG