summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qwavedecoder_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio/qwavedecoder_p.cpp')
-rw-r--r--src/multimedia/audio/qwavedecoder_p.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/multimedia/audio/qwavedecoder_p.cpp b/src/multimedia/audio/qwavedecoder_p.cpp
index 497a146df..974a8f509 100644
--- a/src/multimedia/audio/qwavedecoder_p.cpp
+++ b/src/multimedia/audio/qwavedecoder_p.cpp
@@ -166,6 +166,8 @@ void QWaveDecoder::handleData()
// Swizzle this
if (bigEndian) {
wave.audioFormat = qFromBigEndian<quint16>(wave.audioFormat);
+ } else {
+ wave.audioFormat = qFromLittleEndian<quint16>(wave.audioFormat);
}
if (wave.audioFormat != 0 && wave.audioFormat != 1) {
@@ -207,6 +209,8 @@ void QWaveDecoder::handleData()
source->read(reinterpret_cast<char *>(&descriptor), sizeof(chunk));
if (bigEndian)
descriptor.size = qFromBigEndian<quint32>(descriptor.size);
+ else
+ descriptor.size = qFromLittleEndian<quint32>(descriptor.size);
dataSize = descriptor.size;
@@ -227,13 +231,15 @@ void QWaveDecoder::handleData()
bool QWaveDecoder::enoughDataAvailable()
{
chunk descriptor;
- if (!peekChunk(&descriptor))
+ if (!peekChunk(&descriptor, false))
return false;
// This is only called for the RIFF/RIFX header, before bigEndian is set,
// so we have to manually swizzle
if (qstrncmp(descriptor.id, "RIFX", 4) == 0)
descriptor.size = qFromBigEndian<quint32>(descriptor.size);
+ if (qstrncmp(descriptor.id, "RIFF", 4) == 0)
+ descriptor.size = qFromLittleEndian<quint32>(descriptor.size);
if (source->bytesAvailable() < qint64(sizeof(chunk) + descriptor.size))
return false;
@@ -270,16 +276,18 @@ bool QWaveDecoder::findChunk(const char *chunkId)
return false;
}
-// Handles endianness
-bool QWaveDecoder::peekChunk(chunk *pChunk)
+bool QWaveDecoder::peekChunk(chunk *pChunk, bool handleEndianness)
{
if (source->bytesAvailable() < qint64(sizeof(chunk)))
return false;
source->peek(reinterpret_cast<char *>(pChunk), sizeof(chunk));
- if (bigEndian)
- pChunk->size = qFromBigEndian<quint32>(pChunk->size);
-
+ if (handleEndianness) {
+ if (bigEndian)
+ pChunk->size = qFromBigEndian<quint32>(pChunk->size);
+ else
+ pChunk->size = qFromLittleEndian<quint32>(pChunk->size);
+ }
return true;
}