Bug 1398139 - part1 : revert the changing of bug 1386478. r=jwwang
authorAlastor Wu <alwu@mozilla.com>
Fri, 15 Sep 2017 17:07:08 +0800
changeset 665693 1421239eef77ff58aaf7883a366d8f97536cdfa2
parent 665692 3cb1ce131f7cab332f036cecd59e5d104c981fa8
child 665694 9fe90be81abbcc63f2c0aab66222eb867b968990
push id80148
push userbmo:emilio@crisal.io
push dateFri, 15 Sep 2017 20:59:22 +0000
reviewersjwwang
bugs1398139, 1386478
milestone57.0a1
Bug 1398139 - part1 : revert the changing of bug 1386478. r=jwwang This changing causes the resampling rate tolerance so that the ME.current time might not be the same as ME.duration depending on the different resampling rate. MozReview-Commit-ID: H2dpyw5Bghv
dom/media/mediasink/AudioSink.cpp
--- a/dom/media/mediasink/AudioSink.cpp
+++ b/dom/media/mediasink/AudioSink.cpp
@@ -226,17 +226,19 @@ AudioSink::GetEndTime() const
     MonitorAutoLock mon(mMonitor);
     written = mWritten;
   }
   TimeUnit played = FramesToTimeUnit(written, mOutputRate) + mStartTime;
   if (!played.IsValid()) {
     NS_WARNING("Int overflow calculating audio end time");
     return TimeUnit::Zero();
   }
-  return played;
+  // As we may be resampling, rounding errors may occur. Ensure we never get
+  // past the original end time.
+  return std::min(mLastEndTime, played);
 }
 
 UniquePtr<AudioStream::Chunk>
 AudioSink::PopFrames(uint32_t aFrames)
 {
   class Chunk : public AudioStream::Chunk {
   public:
     Chunk(AudioData* aBuffer, uint32_t aFrames, AudioDataValue* aData)