Fixed bug in QWaveDecoder.
When looking for a specific chunk, it was entering an infinite loop if not finding it in the next two chunks available. It now correctly tries to find the chunk until it reaches the end of the IO device. Change-Id: I29252318566fe3a47f267410c91dacaf302d9618 Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
edc76ed071
commit
f01af490a0
@@ -244,6 +244,8 @@ bool QWaveDecoder::enoughDataAvailable()
|
|||||||
bool QWaveDecoder::findChunk(const char *chunkId)
|
bool QWaveDecoder::findChunk(const char *chunkId)
|
||||||
{
|
{
|
||||||
chunk descriptor;
|
chunk descriptor;
|
||||||
|
|
||||||
|
do {
|
||||||
if (!peekChunk(&descriptor))
|
if (!peekChunk(&descriptor))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -253,7 +255,7 @@ bool QWaveDecoder::findChunk(const char *chunkId)
|
|||||||
// It's possible that bytes->available() is less than the chunk size
|
// It's possible that bytes->available() is less than the chunk size
|
||||||
// if it's corrupt.
|
// if it's corrupt.
|
||||||
junkToSkip = qint64(sizeof(chunk) + descriptor.size);
|
junkToSkip = qint64(sizeof(chunk) + descriptor.size);
|
||||||
while (source->bytesAvailable() > 0) {
|
|
||||||
// Skip the current amount
|
// Skip the current amount
|
||||||
if (junkToSkip > 0)
|
if (junkToSkip > 0)
|
||||||
discardBytes(junkToSkip);
|
discardBytes(junkToSkip);
|
||||||
@@ -263,12 +265,7 @@ bool QWaveDecoder::findChunk(const char *chunkId)
|
|||||||
if (junkToSkip > 0)
|
if (junkToSkip > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!peekChunk(&descriptor))
|
} while (source->bytesAvailable() > 0);
|
||||||
return false;
|
|
||||||
|
|
||||||
if (qstrncmp(descriptor.id, chunkId, 4) == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user