Bug 1112438 - Make newCurrentFrameTime more accurate while seeking by checking audio & video timestamp boundary in addition. r=cpearce
authorKilik Kuo <kikuo@mozilla.com>
Tue, 17 Feb 2015 11:21:40 +0800
changeset 229811 4b812ca945b22f33c15417ff40f396dfb3fe0a25
parent 229810 dad2219de6a3d2e0a06e0f8019aab71297b10d60
child 229812 813b4d13bcc3c27d27a65f07a2566653065776df
push id13981
push userryanvm@gmail.com
push dateThu, 19 Feb 2015 15:44:22 +0000
treeherderb2g-inbound@4b812ca945b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1112438
milestone38.0a1
Bug 1112438 - Make newCurrentFrameTime more accurate while seeking by checking audio & video timestamp boundary in addition. r=cpearce
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2587,17 +2587,26 @@ MediaDecoderStateMachine::SeekCompleted(
   int64_t newCurrentTime = mCurrentSeekTarget.mTime;
 
   // Setup timestamp state.
   VideoData* video = VideoQueue().PeekFront();
   if (seekTime == mEndTime) {
     newCurrentTime = mAudioStartTime = seekTime;
   } else if (HasAudio()) {
     AudioData* audio = AudioQueue().PeekFront();
-    newCurrentTime = mAudioStartTime = audio ? audio->mTime : seekTime;
+    // Though we adjust the newCurrentTime in audio-based, and supplemented
+    // by video. For better UX, should NOT bind the slide position to
+    // the first audio data timestamp directly.
+    // While seeking to a position where there's only either audio or video, or
+    // seeking to a position lies before audio or video, we need to check if
+    // seekTime is bounded in suitable duration. See Bug 1112438.
+    int64_t videoStart = video ? video->mTime : seekTime;
+    int64_t audioStart = audio ? audio->mTime : seekTime;
+    newCurrentTime = mAudioStartTime =
+        std::min(std::min(audioStart, videoStart), seekTime);
   } else {
     newCurrentTime = video ? video->mTime : seekTime;
   }
   mPlayDuration = newCurrentTime - mStartTime;
 
   if (HasVideo()) {
     if (video) {
       {