Bug 1248909: [MSE] P2. Simplify diagnostic. r=gerald, a=sylvestre
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 18 Feb 2016 15:27:48 +1100
changeset 313171 7da232006437a6e23eae84ac9884ef05a113814c
parent 313170 26f6a1a3106bf9462c005a15cf1bbfbf572fa97c
child 313172 5154bb929236be80e13fd8aca413bb699321dd56
push id1040
push userraliiev@mozilla.com
push dateMon, 29 Feb 2016 17:11:22 +0000
treeherdermozilla-release@8c3167321162 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, sylvestre
bugs1248909
milestone45.0
Bug 1248909: [MSE] P2. Simplify diagnostic. r=gerald, a=sylvestre Also, an assert could have been incorrectly triggered, if eviction occurred on a source buffer while data was also being appended to it. MozReview-Commit-ID: 6gVHZdbL07B
dom/media/mediasource/TrackBuffersManager.cpp
dom/media/mediasource/TrackBuffersManager.h
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -102,17 +102,16 @@ TrackBuffersManager::TrackBuffersManager
   , mTaskQueue(aParentDecoder->GetDemuxer()->GetTaskQueue())
   , mSourceBufferAttributes(aAttributes)
   , mParentDecoder(new nsMainThreadPtrHolder<MediaSourceDecoder>(aParentDecoder, false /* strict */))
   , mEvictionThreshold(Preferences::GetUint("media.mediasource.eviction_threshold",
                                             100 * (1 << 20)))
   , mEvictionOccurred(false)
   , mMonitor("TrackBuffersManager")
   , mAppendRunning(false)
-  , mSegmentParserLoopRunning(false)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Must be instanciated on the main thread");
 }
 
 TrackBuffersManager::~TrackBuffersManager()
 {
   ShutdownDemuxers();
 }
@@ -299,17 +298,16 @@ TrackBuffersManager::Detach()
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("");
 }
 
 void
 TrackBuffersManager::CompleteResetParserState()
 {
   MOZ_ASSERT(OnTaskQueue());
-  MOZ_DIAGNOSTIC_ASSERT(!mSegmentParserLoopRunning);
   MSE_DEBUG("");
 
   for (auto& track : GetTracksList()) {
     // 2. Unset the last decode timestamp on all track buffers.
     // 3. Unset the last frame duration on all track buffers.
     // 4. Unset the highest end timestamp on all track buffers.
     // 5. Set the need random access point flag on all track buffers to true.
     track->ResetAppendState();
@@ -435,17 +433,16 @@ TrackBuffersManager::CodedFrameRemovalWi
   bool rv = CodedFrameRemoval(aInterval);
   return RangeRemovalPromise::CreateAndResolve(rv, __func__);
 }
 
 bool
 TrackBuffersManager::CodedFrameRemoval(TimeInterval aInterval)
 {
   MOZ_ASSERT(OnTaskQueue());
-  MOZ_ASSERT(!mSegmentParserLoopRunning, "Logic error: Append in progress");
   MSE_DEBUG("From %.2fs to %.2f",
             aInterval.mStart.ToSeconds(), aInterval.mEnd.ToSeconds());
 
 #if DEBUG
   if (HasVideo()) {
     MSE_DEBUG("before video ranges=%s",
               DumpTimeRanges(mVideoTracks.mBufferedRanges).get());
   }
@@ -574,18 +571,16 @@ TrackBuffersManager::AppendIncomingBuffe
                  TimeUnit::FromSeconds(mSourceBufferAttributes->GetAppendWindowEnd()));
 }
 
 void
 TrackBuffersManager::SegmentParserLoop()
 {
   MOZ_ASSERT(OnTaskQueue());
 
-  mSegmentParserLoopRunning = true;
-
   while (true) {
     // 1. If the input buffer is empty, then jump to the need more data step below.
     if (!mInputBuffer || mInputBuffer->IsEmpty()) {
       NeedMoreData();
       return;
     }
     // 2. If the input buffer contains bytes that violate the SourceBuffer
     // byte stream format specification, then run the append error algorithm with
@@ -700,31 +695,29 @@ TrackBuffersManager::SegmentParserLoop()
 }
 
 void
 TrackBuffersManager::NeedMoreData()
 {
   MSE_DEBUG("");
   RestoreCachedVariables();
   mAppendRunning = false;
-  mSegmentParserLoopRunning = false;
   {
     // Wake-up any pending Abort()
     MonitorAutoLock mon(mMonitor);
     mon.NotifyAll();
   }
   mAppendPromise.ResolveIfExists(mActiveTrack, __func__);
 }
 
 void
 TrackBuffersManager::RejectAppend(nsresult aRejectValue, const char* aName)
 {
   MSE_DEBUG("rv=%d", aRejectValue);
   mAppendRunning = false;
-  mSegmentParserLoopRunning = false;
   {
     // Wake-up any pending Abort()
     MonitorAutoLock mon(mMonitor);
     mon.NotifyAll();
   }
   mAppendPromise.RejectIfExists(aRejectValue, aName);
 }
 
--- a/dom/media/mediasource/TrackBuffersManager.h
+++ b/dom/media/mediasource/TrackBuffersManager.h
@@ -345,21 +345,18 @@ private:
   // Global size of this source buffer content.
   Atomic<int64_t> mSizeSourceBuffer;
   uint32_t mEvictionThreshold;
   Atomic<bool> mEvictionOccurred;
 
   // Monitor to protect following objects accessed across multipple threads.
   // mMonitor is also notified if the value of mAppendRunning becomes false.
   mutable Monitor mMonitor;
-  // Set to true while SegmentParserLoop is running.
+  // Set to true while a BufferAppend is running or is pending.
   Atomic<bool> mAppendRunning;
-  // Set to true while SegmentParserLoop is running.
-  // This is for diagnostic only. Only accessed on the task queue.
-  bool mSegmentParserLoopRunning;
   // Stable audio and video track time ranges.
   media::TimeIntervals mVideoBufferedRanges;
   media::TimeIntervals mAudioBufferedRanges;
   media::TimeUnit mOfficialGroupEndTimestamp;
   // MediaInfo of the first init segment read.
   MediaInfo mInfo;
 };