From db70e38a67cd715ca910b1075c1152ffa30ba9cc Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Thu, 14 Apr 2011 10:12:23 +1200 Subject: [PATCH] Bug 641718 - Round nsWaveReader's buffered ranges times to usecs. r=kinetik --- content/media/test/Makefile.in | 1 + content/media/test/audio.wav | Bin 0 -> 1422 bytes content/media/test/manifest.js | 1 + content/media/wave/nsWaveReader.cpp | 11 +++++++++-- 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 content/media/test/audio.wav diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in index e9f317bd4ac8..a538b7550a00 100644 --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -231,6 +231,7 @@ _TEST_FILES += \ r16000_u8_c1_list.wav \ wavedata_u8.wav \ wavedata_s16.wav \ + audio.wav \ $(NULL) # Other files diff --git a/content/media/test/audio.wav b/content/media/test/audio.wav new file mode 100644 index 0000000000000000000000000000000000000000..c6fd5cb869351be1b0fd2ccbdac51eb77066f464 GIT binary patch literal 1422 zcmYk6drVVj7{==#%h=rFoVu|v)QKLmI4)8YALjoQrbfAH+rKj zEwly7r3C@Yog#O%(0VCa&~7o&Y%ZEPqw%^Jr~bS5v|Hxyh`d^m2jZ$|l@%3K zYB>UxT2V=>VlY{?oI0LBB$YR)G&+OHY-w$`b#!*y?G6OHy}P@!!`9wvH8-1@^g4}7 zsgOyFeogx0v*5xtPbUrcsE5f)hDe z=)(v1r=@y*^AeFqL5L1!Mz&BNl0OUo!!dNqs76G|1T zMuXAZYU^_J_B)56=G4sG!s2=N(z3_n^?E&??b|&GvC%uWMuczK zv~j}+>)#6tdlw<>{q-Mi*tj`7Vq4UgyOUDV4yI>g@Fl0{ES^+luyphej!!Rod~3hl z{O!)Y2aliq_2T8L*KgjudHw3|moJ__ee~eZySH!M2>5+o_x$w4h_lbp*#^ey!B_}4 zGH5Vq0CYbHj2$Gep37!28T5*BGO?r>k2`_MJ)WJFnSo9}8YDd(jn2r-{4p#0cuww5 zm^_F97KbY+z~c)c2t~yJfpGFSXRt38aJ2u#7Z*S47B)nQW zr39aM41H){YI0&+Ow{(si11IhY~J)Suxay_Pr^Toh}<3(6T3SxIpw?k2ajZA5|RwY62h-+%S$m6a8r@A9RK z7d*>LZiw9c-0bw!Sr<%AaA^8M_FK)SCY@F(mk4=WRyD1hTuLa!=H+B(9z`O!H#H?W zDRFn~u9)bZJHFVqb!%kg=LnIJ+jd0ljE>nApYT<3%HHn}{D96nj=>Q~<@B05kwVjC zu{j1tCTGukeg43WTet80asT0?Cr_U}2cA8B^7!HXdv|~T_2!Mh>dHlrdtqjBY}nb? W(`{?BwwMe$tyGetCurrentStream()->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); @@ -282,8 +286,11 @@ nsresult nsWaveReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime) 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;