AUDIO: Skip JUNK padding in WAV files

Some wave files may contain a JUNK chunk before the
'fmt ' chunk, used for padding. This should be skipped when reading the header.
This commit is contained in:
Walter Agazzi 2023-05-27 10:49:05 +02:00 committed by Filippos Karapetis
parent 70b1a4432a
commit 9f802a181e

View File

@ -62,6 +62,13 @@ bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate,
stream.read(buf, 4);
}
if (memcmp(buf, "JUNK", 4) == 0) {
uint32 junksize = stream.readUint32LE();
// skip junk padding (add 1 byte if odd)
stream.skip(junksize + (junksize % 2));
stream.read(buf, 4);
}
if (memcmp(buf, "fmt ", 4) != 0) {
warning("getWavInfo: No 'fmt' header");
return false;