Bug 1341200. Part 3 - replace mShutdownRequest with a bool as P2. r=jya
authorJW Wang <jwwang@mozilla.com>
Fri, 24 Feb 2017 17:19:12 +0800
changeset 394805 5f0dca380e8448d3f82becbd0947933b1c7769f5
parent 394804 e9fc566fda857777a9915babda95b7cfd62f56ad
child 394806 e353098c37d208361b46fd8cb9fb32be87c0d6d6
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1341200
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1341200. Part 3 - replace mShutdownRequest with a bool as P2. r=jya MozReview-Commit-ID: ERERt0ZyvkC
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1080,17 +1080,17 @@ MediaFormatReader::ShutdownDecoderWithPr
   if (!decoder.mFlushed && decoder.mDecoder) {
     // The decoder has yet to be flushed.
     // We always flush the decoder prior to a shutdown to ensure that all the
     // potentially pending operations on the decoder are completed.
     decoder.Flush();
     return decoder.mShutdownPromise.Ensure(__func__);
   }
 
-  if (decoder.mFlushing || decoder.mShutdownRequest.Exists()) {
+  if (decoder.mFlushing || decoder.mShuttingDown) {
     // Let the current flush or shutdown operation complete, Flush will continue
     // shutting down the current decoder now that the shutdown promise is set.
     return decoder.mShutdownPromise.Ensure(__func__);
   }
 
   if (!decoder.mDecoder) {
     // Shutdown any decoders that may be in the process of being initialized
     // in the Decoder Factory.
@@ -1887,17 +1887,17 @@ MediaFormatReader::DecodeDemuxedSamples(
 void
 MediaFormatReader::HandleDemuxedSamples(
   TrackType aTrack, AbstractMediaDecoder::AutoNotifyDecoded& aA)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   auto& decoder = GetDecoderData(aTrack);
 
-  if (decoder.mFlushing || decoder.mShutdownRequest.Exists()) {
+  if (decoder.mFlushing || decoder.mShuttingDown) {
     LOGV("Decoder operation in progress, let it complete.");
     return;
   }
 
   if (decoder.mQueuedSamples.IsEmpty()) {
     return;
   }
 
@@ -2270,17 +2270,17 @@ MediaFormatReader::Update(TrackType aTra
     TrackTypeToStr(aTrack),
     needInput,
     needOutput,
     decoder.mNumSamplesInput,
     decoder.mNumSamplesOutput,
     uint32_t(size_t(decoder.mSizeOfQueue)),
     decoder.mDecodeRequest.Exists(),
     decoder.mFlushing,
-    decoder.mShutdownRequest.Exists(),
+    decoder.mShuttingDown,
     uint32_t(decoder.mOutput.Length()),
     decoder.mWaitingForData,
     decoder.mLastStreamSourceID);
 
   if ((decoder.mWaitingForData
        && (!decoder.mTimeThreshold || decoder.mTimeThreshold.ref().mWaiting))
       || (decoder.mWaitingForKey && decoder.mDecodeRequest.Exists())) {
     // Nothing more we can do at present.
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -217,25 +217,25 @@ private:
     void ShutdownDecoder()
     {
       MutexAutoLock lock(mMutex);
       if (mDecoder) {
         RefPtr<MediaFormatReader> owner = mOwner;
         TrackType type = mType == MediaData::AUDIO_DATA
                          ? TrackType::kAudioTrack
                          : TrackType::kVideoTrack;
+        mShuttingDown = true;
         mDecoder->Shutdown()
           ->Then(mOwner->OwnerThread(), __func__,
                  [owner, this, type]() {
-                   mShutdownRequest.Complete();
+                   mShuttingDown = false;
                    mShutdownPromise.ResolveIfExists(true, __func__);
                    owner->ScheduleUpdate(type);
                  },
-                 []() { MOZ_RELEASE_ASSERT(false, "Can't ever be here"); })
-          ->Track(mShutdownRequest);
+                 []() { MOZ_RELEASE_ASSERT(false, "Can't ever be here"); });
       }
       mDescription = "shutdown";
       mDecoder = nullptr;
     }
 
     // Only accessed from reader's task queue.
     bool mUpdateScheduled;
     bool mDemuxEOS;
@@ -264,17 +264,17 @@ private:
     }
 
     // MediaDataDecoder handler's variables.
     MozPromiseRequestHolder<MediaDataDecoder::DecodePromise> mDecodeRequest;
     bool mFlushing; // True if flush is in action.
     // Set to true if the last operation run on the decoder was a flush.
     bool mFlushed;
     MozPromiseHolder<ShutdownPromise> mShutdownPromise;
-    MozPromiseRequestHolder<ShutdownPromise> mShutdownRequest;
+    bool mShuttingDown = false; // True if shutdown is in action.
 
     MozPromiseRequestHolder<MediaDataDecoder::DecodePromise> mDrainRequest;
     DrainState mDrainState;
     bool HasPendingDrain() const
     {
       return mDrainState != DrainState::None;
     }
     void RequestDrain()