diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2014-03-17 08:44:24 +0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-03 15:37:33 +0200 |
commit | b0c68a1a07f546fe22a7d76b1a15bb2b39aa550f (patch) | |
tree | 43927962b90a4aeb891d36ed5890dd8383ddbf0b /src/multimedia/audio | |
parent | 3d51c9565da75b533926ca8bb98fe5746fc37d3b (diff) | |
download | qtmultimedia-b0c68a1a07f546fe22a7d76b1a15bb2b39aa550f.tar.gz |
Add support for running on big-endian systems
Now qtmultimedia test suite passes on powerpc.
Change-Id: I540dff93195115ad1dc5725af7293e3b8540403f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r-- | src/multimedia/audio/qwavedecoder_p.cpp | 20 | ||||
-rw-r--r-- | src/multimedia/audio/qwavedecoder_p.h | 2 |
2 files changed, 15 insertions, 7 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; } diff --git a/src/multimedia/audio/qwavedecoder_p.h b/src/multimedia/audio/qwavedecoder_p.h index c21d8cb5b..24cdb7885 100644 --- a/src/multimedia/audio/qwavedecoder_p.h +++ b/src/multimedia/audio/qwavedecoder_p.h @@ -103,7 +103,7 @@ private: char id[4]; quint32 size; }; - bool peekChunk(chunk* pChunk); + bool peekChunk(chunk* pChunk, bool handleEndianness = true); struct RIFFHeader { |