aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-07-22 08:51:00 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-07-22 08:51:00 +0000
commitff28a947df32728be80c7739e377bcb3ea43861f (patch)
tree8bc47c9d37413370b2541df10695202117b078c6 /src/plugins
parentdac61f7c6d05d85cf6eff7cdae39324e081735cc (diff)
downloadqmmp-ff28a947df32728be80c7739e377bcb3ea43861f.tar.gz
qmmp-ff28a947df32728be80c7739e377bcb3ea43861f.tar.bz2
qmmp-ff28a947df32728be80c7739e377bcb3ea43861f.zip
sndfile: fixed issue with 'JUNK' and 'bext' chunks (#970)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8207 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Input/sndfile/decodersndfilefactory.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.cpp b/src/plugins/Input/sndfile/decodersndfilefactory.cpp
index d2cedb38c..7097fd87e 100644
--- a/src/plugins/Input/sndfile/decodersndfilefactory.cpp
+++ b/src/plugins/Input/sndfile/decodersndfilefactory.cpp
@@ -38,13 +38,45 @@
// DecoderSndFileFactory
bool DecoderSndFileFactory::canDecode(QIODevice *input) const
{
- char buf[36];
+ char buf[36] = {0};
if(input->peek(buf, sizeof(buf)) != sizeof(buf))
return false;
if(!memcmp(buf + 8, "WAVE", 4) && (!memcmp(buf, "RIFF", 4) || !memcmp(buf, "RIFX", 4)))
{
- quint16 subformat = (quint16(buf[21]) << 8) + buf[20];
+ quint16 subformat = 0;
+
+ if(!memcmp(buf + 12, "fmt ", 4))
+ {
+ subformat = (quint16(buf[21]) << 8) + buf[20];
+ }
+ else if(!input->isSequential())
+ {
+ input->seek(12);
+ //skip "JUNK" and "bext" chunks
+ while(!input->atEnd())
+ {
+ if(input->peek(buf, sizeof(buf)) != sizeof(buf))
+ return false;
+
+ if(!memcmp(buf, "fmt ", 4))
+ {
+ subformat = (quint16(buf[9]) << 8) + buf[8];
+ break;
+ }
+ else if(!memcmp(buf, "JUNK", 4) || !memcmp(buf, "bext", 4))
+ {
+ size_t size = buf[4] + (buf[5] << 8) + (buf[6] << 16) + (buf[7] << 24);
+ if(!input->seek(input->pos() + size + 8))
+ break;
+ }
+ else
+ {
+ break;
+ }
+ }
+ input->seek(0);
+ }
switch (subformat)
{