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);
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;
}