Bug 1089586 - Abort pending seeks. r=jwwang, a=sylvestre
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 28 Sep 2015 15:23:28 +1000
changeset 296165 f8c3934ab6145a130593965a7c4e80fb87f7d358
parent 296164 26bc92aef3ad49485b6d6a5cc1e7bbbe17db3764
child 296166 c0526447cff40675719d5ac0eb1ce04d175d94af
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, sylvestre
bugs1089586
milestone43.0a2
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
@@ -1406,25 +1406,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();
   }
 }