summaryrefslogtreecommitdiff
path: root/src/multimedia
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2013-07-24 13:01:08 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-05 18:08:53 +0200
commitf01af490a0be13219deb0499c210ceee700332ba (patch)
tree6bbb887a06b42a48a2650c1e3cc873ce530d8b26 /src/multimedia
parentedc76ed07104d5eb54c83abd845178bc9b1cfb1d (diff)
downloadqtmultimedia-f01af490a0be13219deb0499c210ceee700332ba.tar.gz
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>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/audio/qwavedecoder_p.cpp25
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;
}