Bug 1134064 - Part 4: Fix racing condition should data get evicted. r=mattwoodrow, a=lsblakk
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 24 Feb 2015 16:38:41 +1100
changeset 250101 c92f6beaa505
parent 250100 5f400332977d
child 250102 d461222b1a07
push id4502
push userryanvm@gmail.com
push date2015-02-27 21:16 +0000
treeherdermozilla-beta@9fb3cc1f7ff6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, lsblakk
bugs1134064
milestone37.0
Bug 1134064 - Part 4: Fix racing condition should data get evicted. r=mattwoodrow, a=lsblakk Should required data get evicted between the time we checked for availability and the time we started seeking, it would have caused the seek to fail. Instead cancel current seek and go back waiting for more data.
dom/media/mediasource/MediaSourceReader.cpp
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -805,18 +805,22 @@ MediaSourceReader::OnVideoSeekFailed(nsr
   mVideoSeekRequest.Complete();
   mPendingSeekTime = -1;
   mSeekPromise.Reject(aResult, __func__);
 }
 
 void
 MediaSourceReader::DoAudioSeek()
 {
-  SwitchAudioSource(&mPendingSeekTime);
-  MOZ_ASSERT(GetAudioReader());
+  if (SwitchAudioSource(&mPendingSeekTime) == SOURCE_NONE) {
+    // Data we need got evicted since the last time we checked for data
+    // availability. Abort current seek attempt.
+    mWaitingForSeekData = true;
+    return;
+  }
   mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(mPendingSeekTime), 0)
                          ->RefableThen(GetTaskQueue(), __func__, this,
                                        &MediaSourceReader::OnAudioSeekCompleted,
                                        &MediaSourceReader::OnAudioSeekFailed));
   MSE_DEBUG("reader=%p", GetAudioReader());
 }
 
 void
@@ -871,18 +875,22 @@ MediaSourceReader::AttemptSeek()
   } else {
     MOZ_CRASH();
   }
 }
 
 void
 MediaSourceReader::DoVideoSeek()
 {
-  SwitchVideoSource(&mPendingSeekTime);
-  MOZ_ASSERT(GetVideoReader());
+  if (SwitchVideoSource(&mPendingSeekTime) == SOURCE_NONE) {
+    // Data we need got evicted since the last time we checked for data
+    // availability. Abort current seek attempt.
+    mWaitingForSeekData = true;
+    return;
+  }
   mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(mPendingSeekTime), 0)
                           ->RefableThen(GetTaskQueue(), __func__, this,
                                         &MediaSourceReader::OnVideoSeekCompleted,
                                         &MediaSourceReader::OnVideoSeekFailed));
   MSE_DEBUG("reader=%p", GetVideoReader());
 }
 
 nsresult