Bug 1135170 - Remove silly special case for seeking to exactly the current time. r=mattwoodrow
authorBobby Holley <bobbyholley@gmail.com>
Fri, 20 Feb 2015 14:42:54 -0800
changeset 232364 371ab272ec4b26bdec7dd5d89eb1ddaf7181db6a
parent 232363 bded539d04a306b32e02159a0a54d2885f5fca55
child 232365 1f94498ba81cd767a584e975edc18f8b3f5d84e0
push id56528
push userbobbyholley@gmail.com
push dateSat, 07 Mar 2015 03:18:56 +0000
treeherdermozilla-inbound@cb5ec48a3391 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1135170
milestone39.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 1135170 - Remove silly special case for seeking to exactly the current time. r=mattwoodrow I traced this back to something 2011 or earlier and then gave up. Given that we're doing an exact microsecond comparison here this is almost certainly dead code in every case except for the one where the media is paused and JS does |el.currentTime = el.currentTime|. And in that case, I think running through the regular seek machinery is probably fine.
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2451,26 +2451,22 @@ void MediaDecoderStateMachine::DecodeSee
   // These calls are made outside of the decode monitor lock so
   // it is safe for the main thread to makes calls that acquire
   // the lock since it won't deadlock. We check the state when
   // acquiring the lock again in case shutdown has occurred
   // during the time when we didn't have the lock.
   int64_t seekTime = mCurrentSeekTarget.mTime;
   mDecoder->StopProgressUpdates();
 
-  bool currentTimeChanged = false;
   mCurrentTimeBeforeSeek = GetMediaTime();
-  if (mCurrentTimeBeforeSeek != seekTime) {
-    currentTimeChanged = true;
-    // Stop playback now to ensure that while we're outside the monitor
-    // dispatching SeekingStarted, playback doesn't advance and mess with
-    // mCurrentFrameTime that we've setting to seekTime here.
-    StopPlayback();
-    UpdatePlaybackPositionInternal(seekTime);
-  }
+  // Stop playback now to ensure that while we're outside the monitor
+  // dispatching SeekingStarted, playback doesn't advance and mess with
+  // mCurrentFrameTime that we've setting to seekTime here.
+  StopPlayback();
+  UpdatePlaybackPositionInternal(seekTime);
 
   // SeekingStarted will do a UpdateReadyStateForData which will
   // inform the element and its users that we have no frames
   // to display
   {
     ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
     nsCOMPtr<nsIRunnable> startEvent =
       NS_NewRunnableMethodWithArg<MediaDecoderEventVisibility>(
@@ -2481,51 +2477,40 @@ void MediaDecoderStateMachine::DecodeSee
   }
   if (mState != DECODER_STATE_SEEKING) {
     // May have shutdown while we released the monitor.
     return;
   }
 
   mDecodeToSeekTarget = false;
 
-  if (!currentTimeChanged) {
-    DECODER_LOG("Seek !currentTimeChanged...");
-    mDropAudioUntilNextDiscontinuity = false;
-    mDropVideoUntilNextDiscontinuity = false;
-    nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(this, &MediaDecoderStateMachine::SeekCompleted);
-    nsresult rv = GetStateMachineThread()->Dispatch(task, NS_DISPATCH_NORMAL);
-    if (NS_FAILED(rv)) {
-      DecodeError();
+  // The seek target is different than the current playback position,
+  // we'll need to seek the playback position, so shutdown our decode
+  // thread and audio sink.
+  StopAudioThread();
+  ResetPlayback();
+
+  nsresult res;
+  {
+    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
+    // We must not hold the state machine monitor while we call into
+    // the reader, since it could do I/O or deadlock some other way.
+    res = mReader->ResetDecode();
+    if (NS_SUCCEEDED(res)) {
+      mReader->Seek(seekTime, GetEndTime())
+             ->Then(DecodeTaskQueue(), __func__, this,
+                    &MediaDecoderStateMachine::OnSeekCompleted,
+                    &MediaDecoderStateMachine::OnSeekFailed);
     }
-  } else {
-    // The seek target is different than the current playback position,
-    // we'll need to seek the playback position, so shutdown our decode
-    // thread and audio sink.
-    StopAudioThread();
-    ResetPlayback();
-
-    nsresult res;
-    {
-      ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
-      // We must not hold the state machine monitor while we call into
-      // the reader, since it could do I/O or deadlock some other way.
-      res = mReader->ResetDecode();
-      if (NS_SUCCEEDED(res)) {
-        mReader->Seek(seekTime, GetEndTime())
-               ->Then(DecodeTaskQueue(), __func__, this,
-                      &MediaDecoderStateMachine::OnSeekCompleted,
-                      &MediaDecoderStateMachine::OnSeekFailed);
-      }
-    }
-    if (NS_FAILED(res)) {
-      DecodeError();
-      return;
-    }
-    mWaitingForDecoderSeek = true;
   }
+  if (NS_FAILED(res)) {
+    DecodeError();
+    return;
+  }
+  mWaitingForDecoderSeek = true;
 }
 
 void
 MediaDecoderStateMachine::OnSeekCompleted(int64_t aTime)
 {
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   mWaitingForDecoderSeek = false;
   mCancelingSeek = false;