diff options
-rw-r--r-- | src/multimedia/audio/qwavedecoder_p.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/multimedia/audio/qwavedecoder_p.cpp b/src/multimedia/audio/qwavedecoder_p.cpp index b75bfaf8f..497a146df 100644 --- a/src/multimedia/audio/qwavedecoder_p.cpp +++ b/src/multimedia/audio/qwavedecoder_p.cpp @@ -244,16 +244,18 @@ bool QWaveDecoder::enoughDataAvailable() bool QWaveDecoder::findChunk(const char *chunkId) { chunk descriptor; - if (!peekChunk(&descriptor)) - return false; - if (qstrncmp(descriptor.id, chunkId, 4) == 0) - return true; + do { + if (!peekChunk(&descriptor)) + return false; + + if (qstrncmp(descriptor.id, chunkId, 4) == 0) + return true; + + // It's possible that bytes->available() is less than the chunk size + // if it's corrupt. + junkToSkip = qint64(sizeof(chunk) + descriptor.size); - // It's possible that bytes->available() is less than the chunk size - // if it's corrupt. - junkToSkip = qint64(sizeof(chunk) + descriptor.size); - while (source->bytesAvailable() > 0) { // Skip the current amount if (junkToSkip > 0) discardBytes(junkToSkip); @@ -263,12 +265,7 @@ bool QWaveDecoder::findChunk(const char *chunkId) if (junkToSkip > 0) return false; - if (!peekChunk(&descriptor)) - return false; - - if (qstrncmp(descriptor.id, chunkId, 4) == 0) - return true; - } + } while (source->bytesAvailable() > 0); return false; } |