Backed out changeset 3983dd7e87bb (bug 1309516)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 05 Nov 2016 11:00:29 +0100
changeset 347822 d284ffa5e67381e5a256f9a90d99c0d4ab116913
parent 347821 e94d188473d3063b9fdf3b577734b7e12a661a2a
child 347823 85848a6d19ab9897632380238f3498db07b6f73f
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1309516
milestone52.0a1
backs out3983dd7e87bb7ff524b710d19b27e65df39231e2
Backed out changeset 3983dd7e87bb (bug 1309516)
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1947,23 +1947,37 @@ MediaFormatReader::SetSeekTarget(const S
 {
   MOZ_ASSERT(OnTaskQueue());
 
   SeekTarget target = aTarget;
 
   // Transform the seek target time to the demuxer timeline.
   if (!ForceZeroStartTime()) {
     target.SetTime(aTarget.GetTime() - TimeUnit::FromMicroseconds(StartTime())
-                   + mInfo.mStartTime);
+                   + DemuxStartTime());
   }
 
   mOriginalSeekTarget = target;
   mFallbackSeekTime = mPendingSeekTime = Some(target.GetTime());
 }
 
+TimeUnit
+MediaFormatReader::DemuxStartTime()
+{
+  MOZ_ASSERT(OnTaskQueue());
+  MOZ_ASSERT(!ForceZeroStartTime());
+  MOZ_ASSERT(HasAudio() || HasVideo());
+
+  const TimeUnit startTime =
+    std::min(mAudio.mFirstDemuxedSampleTime.refOr(TimeUnit::FromInfinity()),
+             mVideo.mFirstDemuxedSampleTime.refOr(TimeUnit::FromInfinity()));
+
+  return startTime.IsInfinite() ? TimeUnit::FromMicroseconds(0) : startTime;
+}
+
 void
 MediaFormatReader::ScheduleSeek()
 {
   if (mSeekScheduled) {
     return;
   }
   mSeekScheduled = true;
   OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaFormatReader::AttemptSeek));
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -535,16 +535,17 @@ private:
   // Set to true if any of our track buffers may be blocking.
   bool mTrackDemuxersMayBlock;
 
   // Set the demuxed-only flag.
   Atomic<bool> mDemuxOnly;
 
   // Seeking objects.
   void SetSeekTarget(const SeekTarget& aTarget);
+  media::TimeUnit DemuxStartTime();
   bool IsSeeking() const { return mPendingSeekTime.isSome(); }
   bool IsVideoSeeking() const
   {
     return IsSeeking() && mOriginalSeekTarget.IsVideoOnly();
   }
   void ScheduleSeek();
   void AttemptSeek();
   void OnSeekFailed(TrackType aTrack, const MediaResult& aError);