Bug 1089586 - Abort pending seeks. r=jwwang, a=sylvestre
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 28 Sep 2015 15:23:28 +1000
changeset 289415 b4f6ba961cab364a992b8dfb80e52c590af565fa
parent 289414 607e0b18cc31c0b1b3a4436134c87a76d954ae3c
child 289416 6972fe930f3fd440a638fa1b940d1c508130c141
push id5112
push usercbook@mozilla.com
push dateTue, 29 Sep 2015 12:42:33 +0000
treeherdermozilla-beta@6972fe930f3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, sylvestre
bugs1089586
milestone42.0
Bug 1089586 - Abort pending seeks. r=jwwang, a=sylvestre We only perform the last seek requested instead.
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1365,25 +1365,34 @@ MediaFormatReader::Seek(int64_t aTime, i
     return SeekPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   mOriginalSeekTime = Some(media::TimeUnit::FromMicroseconds(aTime));
   mPendingSeekTime = mOriginalSeekTime;
 
   nsRefPtr<SeekPromise> p = mSeekPromise.Ensure(__func__);
 
-  AttemptSeek();
+  RefPtr<nsIRunnable> task(
+    NS_NewRunnableMethod(this, &MediaFormatReader::AttemptSeek));
+  OwnerThread()->Dispatch(task.forget());
 
   return p;
 }
 
 void
 MediaFormatReader::AttemptSeek()
 {
   MOZ_ASSERT(OnTaskQueue());
+  if (mPendingSeekTime.isNothing()) {
+    return;
+  }
+  // An internal seek may be pending due to Seek queueing multiple tasks calling
+  // AttemptSeek ; we can ignore those by resetting any pending demuxer's seek.
+  mAudio.mSeekRequest.DisconnectIfExists();
+  mVideo.mSeekRequest.DisconnectIfExists();
   if (HasVideo()) {
     DoVideoSeek();
   } else if (HasAudio()) {
     DoAudioSeek();
   } else {
     MOZ_CRASH();
   }
 }