Bug 966311 - Calculate frame size for stereo wave. r=doublec, a=1.2.x+
authorRalph Giles <giles@mozilla.com>
Fri, 31 Jan 2014 13:50:45 -0800
changeset 157032 ccb2bf14748a44d9fe2fa45f9f04f48bfd4aa4ef
parent 157031 8e58efcfab035de2ffe4b31ab4bb5e437ace6c34
child 157033 5f2f869699a3f77c857f6a996682106094a08319
push id446
push userryanvm@gmail.com
push dateSun, 09 Feb 2014 20:44:30 +0000
reviewersdoublec, 1.2.x
bugs966311
milestone26.0
Bug 966311 - Calculate frame size for stereo wave. r=doublec, a=1.2.x+ We were assuming 8-bit WAVE files were mono-only, but this is not necessarily the case.
content/media/wave/WaveReader.cpp
--- a/content/media/wave/WaveReader.cpp
+++ b/content/media/wave/WaveReader.cpp
@@ -421,17 +421,17 @@ WaveReader::LoadFormatChunk(uint32_t aCh
   // RIFF chunks are always word (two byte) aligned.
   NS_ABORT_IF_FALSE(mDecoder->GetResource()->Tell() % 2 == 0,
                     "LoadFormatChunk left resource unaligned");
 
   // Make sure metadata is fairly sane.  The rate check is fairly arbitrary,
   // but the channels check is intentionally limited to mono or stereo
   // when the media is intended for direct playback because that's what the
   // audio backend currently supports.
-  unsigned int actualFrameSize = sampleFormat == 8 ? 1 : 2 * channels;
+  unsigned int actualFrameSize = (sampleFormat == 8 ? 1 : 2) * channels;
   if (rate < 100 || rate > 96000 ||
       (((channels < 1 || channels > MAX_CHANNELS) ||
        (frameSize != 1 && frameSize != 2 && frameSize != 4)) &&
        !mIgnoreAudioOutputFormat) ||
        (sampleFormat != 8 && sampleFormat != 16) ||
       frameSize != actualFrameSize) {
     NS_WARNING("Invalid WAVE metadata");
     return false;