Bug 646819 - Fix incorrect position calculation in nsWaveDecoder::DecodeAudioData causing OOM - r=kinetik
authorChris Double <chris.double@double.co.nz>
Fri, 01 Apr 2011 03:49:07 +1300
changeset 64545 d6da3f26daea892f71c1246daaa6e4a8a4fd4b0e
parent 64544 d2a5747b10b5cb794e18e7d1b2030991e8f6f0a1
child 64546 56c1a338a41f4a52d335a917b29187fbd99cd0fe
push idunknown
push userunknown
push dateunknown
reviewerskinetik
bugs646819
milestone2.2a1pre
Bug 646819 - Fix incorrect position calculation in nsWaveDecoder::DecodeAudioData causing OOM - r=kinetik
content/media/wave/nsWaveReader.cpp
--- a/content/media/wave/nsWaveReader.cpp
+++ b/content/media/wave/nsWaveReader.cpp
@@ -179,17 +179,17 @@ nsresult nsWaveReader::ReadMetadata(nsVi
 }
 
 PRBool nsWaveReader::DecodeAudioData()
 {
   MonitorAutoEnter mon(mMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on state machine thread or decode thread.");
 
-  PRInt64 pos = GetPosition();
+  PRInt64 pos = GetPosition() - mWavePCMOffset;
   PRInt64 len = GetDataLength();
   PRInt64 remaining = len - pos;
   NS_ASSERTION(remaining >= 0, "Current wave position is greater than wave file length");
 
   static const PRInt64 BLOCK_SIZE = 4096;
   PRInt64 readSize = NS_MIN(BLOCK_SIZE, remaining);
   PRInt64 samples = readSize / mSampleSize;