Bug 1340942. Part 3 - pass Data& to DoCreateDecoder. r=gerald
authorJW Wang <jwwang@mozilla.com>
Fri, 17 Feb 2017 15:17:22 +0800
changeset 372790 7a69db46bddc8b9ac2dc715d32d4a5b8855cb39c
parent 372789 22cdad8b34c92dd26228339de45c4aa19888ef6b
child 372791 9806145e3dddd9641d67ee1d7c9b86b51b022f37
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1340942
milestone54.0a1
Bug 1340942. Part 3 - pass Data& to DoCreateDecoder. r=gerald MozReview-Commit-ID: ABHu0tp57AM
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -247,17 +247,17 @@ private:
     RefPtr<MediaDataDecoder> mDecoder;
     MozPromiseRequestHolder<TokenPromise> mTokenRequest;
     MozPromiseRequestHolder<InitPromise> mInitRequest;
     MozPromiseRequestHolder<ShutdownPromise> mShutdownRequest;
     RefPtr<ShutdownPromise> mShutdownPromise;
   } mAudio, mVideo;
 
   void RunStage(Data& aData);
-  MediaResult DoCreateDecoder(TrackType aTrack);
+  MediaResult DoCreateDecoder(Data& aData);
   void DoInitDecoder(TrackType aTrack);
 
   // guaranteed to be valid by the owner.
   const NotNull<MediaFormatReader*> mOwner;
 };
 
 void
 MediaFormatReader::DecoderFactory::CreateDecoder(TrackType aTrack)
@@ -346,17 +346,17 @@ MediaFormatReader::DecoderFactory::RunSt
       break;
     }
 
     case Stage::CreateDecoder: {
       MOZ_ASSERT(aData.mToken);
       MOZ_ASSERT(!aData.mDecoder);
       MOZ_ASSERT(!aData.mInitRequest.Exists());
 
-      MediaResult rv = DoCreateDecoder(aData.mTrack);
+      MediaResult rv = DoCreateDecoder(aData);
       if (NS_FAILED(rv)) {
         NS_WARNING("Error constructing decoders");
         aData.mToken = nullptr;
         aData.mStage = Stage::None;
         mOwner->NotifyError(aData.mTrack, rv);
         return;
       }
 
@@ -370,73 +370,72 @@ MediaFormatReader::DecoderFactory::RunSt
       MOZ_ASSERT(aData.mDecoder);
       MOZ_ASSERT(aData.mInitRequest.Exists());
       break;
     }
   }
 }
 
 MediaResult
-MediaFormatReader::DecoderFactory::DoCreateDecoder(TrackType aTrack)
+MediaFormatReader::DecoderFactory::DoCreateDecoder(Data& aData)
 {
-  auto& ownerData = mOwner->GetDecoderData(aTrack);
-  auto& data = aTrack == TrackInfo::kAudioTrack ? mAudio : mVideo;
+  auto& ownerData = aData.mOwnerData;
 
   auto decoderCreatingError = "error creating audio decoder";
   MediaResult result =
     MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, decoderCreatingError);
 
   if (!mOwner->mPlatform) {
     mOwner->mPlatform = new PDMFactory();
     if (mOwner->IsEncrypted()) {
       MOZ_ASSERT(mOwner->mCDMProxy);
       mOwner->mPlatform->SetCDMProxy(mOwner->mCDMProxy);
     }
   }
 
-  switch (aTrack) {
+  switch (aData.mTrack) {
     case TrackInfo::kAudioTrack: {
-      data.mDecoder = mOwner->mPlatform->CreateDecoder({
+      aData.mDecoder = mOwner->mPlatform->CreateDecoder({
         ownerData.mInfo
         ? *ownerData.mInfo->GetAsAudioInfo()
         : *ownerData.mOriginalInfo->GetAsAudioInfo(),
         ownerData.mTaskQueue,
         mOwner->mCrashHelper,
         ownerData.mIsBlankDecode,
         &result,
-        aTrack,
+        TrackInfo::kAudioTrack,
         &mOwner->OnTrackWaitingForKeyProducer()
       });
       break;
     }
 
     case TrackType::kVideoTrack: {
       // Decoders use the layers backend to decide if they can use hardware decoding,
       // so specify LAYERS_NONE if we want to forcibly disable it.
-      data.mDecoder = mOwner->mPlatform->CreateDecoder({
+      aData.mDecoder = mOwner->mPlatform->CreateDecoder({
         ownerData.mInfo
         ? *ownerData.mInfo->GetAsVideoInfo()
         : *ownerData.mOriginalInfo->GetAsVideoInfo(),
         ownerData.mTaskQueue,
         mOwner->mKnowsCompositor,
         mOwner->GetImageContainer(),
         mOwner->mCrashHelper,
         ownerData.mIsBlankDecode,
         &result,
-        aTrack,
+        TrackType::kVideoTrack,
         &mOwner->OnTrackWaitingForKeyProducer()
       });
       break;
     }
 
     default:
       break;
   }
 
-  if (data.mDecoder) {
+  if (aData.mDecoder) {
     return NS_OK;
   }
 
   ownerData.mDescription = decoderCreatingError;
   return result;
 }
 
 void