Bug 1121692 - Fix potential race condition with mWaitingForSeekData. r=mattwoodrow, a=sledru
authorBobby Holley <bobbyholley@gmail.com>
Fri, 16 Jan 2015 10:58:00 -0800
changeset 242939 871ab0d29bb8
parent 242938 67f6899c6221
child 242940 35f5cf685186
push id4343
push userryanvm@gmail.com
push date2015-01-20 16:38 +0000
treeherdermozilla-beta@c5dfa7d081f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, sledru
bugs1121692
milestone36.0
Bug 1121692 - Fix potential race condition with mWaitingForSeekData. r=mattwoodrow, a=sledru mWaitingForSeekData is modified in NotifyTimeRangesChanged, which is invoked on the main thread. One would hope that all of these other members are only touched on the decode task queue.
dom/media/mediasource/MediaSourceReader.cpp
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -670,16 +670,17 @@ MediaSourceReader::AttemptSeek()
 {
   // Make sure we don't hold the monitor while calling into the reader
   // Seek methods since it can deadlock.
   {
     ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     if (!mWaitingForSeekData || !TrackBuffersContainTime(mPendingSeekTime)) {
       return;
     }
+    mWaitingForSeekData = false;
   }
 
   ResetDecode();
   for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
     mTrackBuffers[i]->ResetDecode();
   }
 
   // Decoding discontinuity upon seek, reset last times to seek target.
@@ -692,21 +693,16 @@ MediaSourceReader::AttemptSeek()
     mVideoReader->Seek(mPendingSeekTime, 0)
                 ->Then(GetTaskQueue(), __func__, this,
                        &MediaSourceReader::OnVideoSeekCompleted,
                        &MediaSourceReader::OnSeekFailed);
     MSE_DEBUG("MediaSourceReader(%p)::Seek video reader=%p", this, mVideoReader.get());
   } else {
     OnVideoSeekCompleted(mPendingSeekTime);
   }
-
-  {
-    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-    mWaitingForSeekData = false;
-  }
 }
 
 nsresult
 MediaSourceReader::GetBuffered(dom::TimeRanges* aBuffered)
 {
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   MOZ_ASSERT(aBuffered->Length() == 0);
   if (mTrackBuffers.IsEmpty()) {