diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-07-26 06:54:54 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-07-26 06:54:54 +0000 |
| commit | d1ead55da26e5bbe044c9dcc9c5420a2339132e8 (patch) | |
| tree | 545161e7d447102545a98111aecadf7cb60026cb /src | |
| parent | d7caead498fcfe600a5bab5eafd16e350688d320 (diff) | |
| download | qmmp-d1ead55da26e5bbe044c9dcc9c5420a2339132e8.tar.gz qmmp-d1ead55da26e5bbe044c9dcc9c5420a2339132e8.tar.bz2 qmmp-d1ead55da26e5bbe044c9dcc9c5420a2339132e8.zip | |
implemented DecoderSndFileFactory::canDecode function
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6599 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/Input/sndfile/decodersndfilefactory.cpp | 46 | ||||
| -rw-r--r-- | src/plugins/Input/sndfile/decodersndfilefactory.h | 2 |
2 files changed, 46 insertions, 2 deletions
diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.cpp b/src/plugins/Input/sndfile/decodersndfilefactory.cpp index c09958d39..bfca5c713 100644 --- a/src/plugins/Input/sndfile/decodersndfilefactory.cpp +++ b/src/plugins/Input/sndfile/decodersndfilefactory.cpp @@ -29,6 +29,12 @@ #include "decoder_sndfile.h" #include "decodersndfilefactory.h" +#define WAVE_FORMAT_PCM 0x0001 +#define WAVE_FORMAT_ADPCM 0x0002 +#define WAVE_FORMAT_IEEE_FLOAT 0x0003 +#define WAVE_FORMAT_ALAW 0x0006 +#define WAVE_FORMAT_MULAW 0x0007 + // DecoderSndFileFactory bool DecoderSndFileFactory::supports(const QString &source) const { @@ -57,8 +63,46 @@ bool DecoderSndFileFactory::supports(const QString &source) const return false; } -bool DecoderSndFileFactory::canDecode(QIODevice *) const +bool DecoderSndFileFactory::canDecode(QIODevice *input) const { + char buf[36]; + 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]; + + switch (subformat) + { + case WAVE_FORMAT_PCM: + case WAVE_FORMAT_ADPCM: + case WAVE_FORMAT_IEEE_FLOAT: + case WAVE_FORMAT_ALAW: + case WAVE_FORMAT_MULAW: + return true; + default: + return false; + } + } + else if(!memcmp(buf, "FORM", 4)) + { + if(!memcmp(buf + 8, "AIFF", 4)) + return true; + if(!memcmp(buf + 8, "8SVX", 4)) + return true; + } + else if(!memcmp(buf, ".snd", 4) || !memcmp(buf, "dns.", 4)) + return true; + else if(!memcmp(buf, "fap ", 4) || !memcmp(buf, " paf", 4)) + return true; + else if(!memcmp(buf, "NIST", 4)) + return true; + else if(!memcmp(buf, "Crea", 4) && !memcmp(buf + 4, "tive", 4)) + return true; + else if(!memcmp(buf, "riff", 4)) + return true; + return false; } diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.h b/src/plugins/Input/sndfile/decodersndfilefactory.h index 3d3d5aca9..150b89d1c 100644 --- a/src/plugins/Input/sndfile/decodersndfilefactory.h +++ b/src/plugins/Input/sndfile/decodersndfilefactory.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2015 by Ilya Kotov * + * Copyright (C) 2007-2016 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * |
