Bug 641718 - Round nsWaveReader's buffered ranges times to usecs. r=kinetik
authorChris Pearce <chris@pearce.org.nz>
Thu, 14 Apr 2011 10:12:23 +1200
changeset 68093 14a336205f226bdf614f0bb737e90d460af680db
parent 68092 f548e43998be6a1bfb24245b8dc03c559150c0d3
child 68094 8a7dadcb59f5e9ec4ac81e7f1dc54a9c2c1ce575
child 68301 9387b78736542a213584405d6a5c67fd9d3a1650
push id19506
push usercpearce@mozilla.com
push dateWed, 13 Apr 2011 23:10:39 +0000
treeherdermozilla-central@14a336205f22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs641718
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 641718 - Round nsWaveReader's buffered ranges times to usecs. r=kinetik
content/media/test/Makefile.in
content/media/test/audio.wav
content/media/test/manifest.js
content/media/wave/nsWaveReader.cpp
--- a/content/media/test/Makefile.in
+++ b/content/media/test/Makefile.in
@@ -226,16 +226,17 @@ endif
 		r11025_msadpcm_c1.wav \
 		r11025_s16_c1.wav \
 		r11025_s16_c1_trailing.wav \
 		r11025_u8_c1.wav \
 		r11025_u8_c1_trunc.wav \
 		r16000_u8_c1_list.wav \
 		wavedata_u8.wav \
 		wavedata_s16.wav \
+		audio.wav \
 		$(NULL)
 
 # Other files
 _TEST_FILES += \
 		bogus.duh \
 		$(NULL)
 
 # These tests contain backend-specific tests. Try to write backend
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c6fd5cb869351be1b0fd2ccbdac51eb77066f464
GIT binary patch
literal 1422
zc${67YfMvj7{=>|Wo&M7PT5!(>O`4bhinYTG{95}a$SLz0u?B=6k19tZQ;;+OK-G=
zLR;>%+{>LJ_e-HwC|b~NG0|);nmMCU!NoZB>;C7|Wy^jiCpkIi<b9v>KF@nFiShCB
zcTgx?9QHi9jCJHA6biKm9OuSR$himQg(4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r@`(Yg5r
zV5rTuYIj_@y5V$gUUzM6-?-^^{{(QmZ{FB;U30EGY)f;O$A|h%txX!a5UQk+^YIxe
z=(y8S5n(|A{zv?LeLnR*c;I8efrH+k_<ZK;cf>y+FeEG@^1Cy!=Ms|AFxVVIA&Ekz
zGuaSND3z<UIzvml39;EaJ-4{LYQM6+v3U)&-`d{Z-g3EI*RNmO+;loO)~{Z%udUiZ
z<QC@VW~MJ&!PX#4)910@sMpo2RWgZ?2XUC?)M8QrAqSh0mYjGVj^L@N$cXT;kiZiG
z$B!NT;_#tEetw_B`1u_^>VNEbz=`0{uOcE(eIN4!Iw=){BM^&e6;*txvfj{U9vGdP
zTX8sD?pt^6-uwOG<0sE{cAo=wcb+|c{P4m3-+sA$%e}RE)oxpyof;pp^mTUuIZZmP
OTBVTHdVXUPndEONLbqQ4
--- a/content/media/test/manifest.js
+++ b/content/media/test/manifest.js
@@ -209,16 +209,17 @@ var gErrorTests = [
   { name:"bug603918.webm", type:"video/webm" },
   { name:"bug604067.webm", type:"video/webm" },
   { name:"bogus.duh", type:"bogus/duh" }
 ];
 
 // These are files that have nontrivial duration and are useful for seeking within.
 var gSeekTests = [
   { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
+  { name:"audio.wav", type:"audio/x-wav", duration:0.031247 },
   { name:"seek.ogv", type:"video/ogg", duration:3.966 },
   { name:"320x240.ogv", type:"video/ogg", duration:0.233 },
   { name:"seek.webm", type:"video/webm", duration:3.966 },
   { name:"bug516323.indexed.ogv", type:"video/ogg", duration:4.208 },
   { name:"split.webm", type:"video/webm", duration:1.967 },
   { name:"bogus.duh", type:"bogus/duh", duration:123 }
 ];
 
--- a/content/media/wave/nsWaveReader.cpp
+++ b/content/media/wave/nsWaveReader.cpp
@@ -268,27 +268,34 @@ nsresult nsWaveReader::Seek(PRInt64 aTar
   PRInt64 duration = static_cast<PRInt64>(d * USECS_PER_S);
   double seekTime = NS_MIN(aTarget, duration) / static_cast<double>(USECS_PER_S);
   PRInt64 position = RoundDownToSample(static_cast<PRInt64>(TimeToBytes(seekTime)));
   NS_ASSERTION(PR_INT64_MAX - mWavePCMOffset > position, "Integer overflow during wave seek");
   position += mWavePCMOffset;
   return mDecoder->GetCurrentStream()->Seek(nsISeekableStream::NS_SEEK_SET, position);
 }
 
+static double RoundToUsecs(double aSeconds) {
+  return floor(aSeconds * USECS_PER_S) / USECS_PER_S;
+}
+
 nsresult nsWaveReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
 {
   PRInt64 startOffset = mDecoder->GetCurrentStream()->GetNextCachedData(mWavePCMOffset);
   while (startOffset >= 0) {
     PRInt64 endOffset = mDecoder->GetCurrentStream()->GetCachedDataEnd(startOffset);
     // Bytes [startOffset..endOffset] are cached.
     NS_ASSERTION(startOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
     NS_ASSERTION(endOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
 
-    aBuffered->Add(BytesToTime(startOffset - mWavePCMOffset),
-                   BytesToTime(endOffset - mWavePCMOffset));
+    // We need to round the buffered ranges' times to microseconds so that they
+    // have the same precision as the currentTime and duration attribute on 
+    // the media element.
+    aBuffered->Add(RoundToUsecs(BytesToTime(startOffset - mWavePCMOffset)),
+                   RoundToUsecs(BytesToTime(endOffset - mWavePCMOffset)));
     startOffset = mDecoder->GetCurrentStream()->GetNextCachedData(endOffset);
   }
   return NS_OK;
 }
 
 PRBool
 nsWaveReader::ReadAll(char* aBuf, PRInt64 aSize, PRInt64* aBytesRead)
 {