Bug 1340942. Part 1 - add some members so we don't have to pass the track type around. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 17 Feb 2017 14:48:42 +0800
changeset 486837 32edcdf089f2ebe6f543355cf67db259ebab1e94
parent 486836 f606545c5fafc439fe4dad363607de36ca45e8f7
child 486838 54d8ffc3d28b2762e86e6f73f36e90e790f0b4eb
push id46073
push userjwwang@mozilla.com
push dateMon, 20 Feb 2017 03:04:34 +0000
bugs1340942
milestone54.0a1
Bug 1340942. Part 1 - add some members so we don't have to pass the track type around. MozReview-Commit-ID: Ewipsg8FFqb
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -189,17 +189,21 @@ DecoderAllocPolicy::operator=(std::nullp
 
 class MediaFormatReader::DecoderFactory
 {
   using InitPromise = MediaDataDecoder::InitPromise;
   using TokenPromise = DecoderAllocPolicy::Promise;
   using Token = DecoderAllocPolicy::Token;
 
 public:
-  explicit DecoderFactory(MediaFormatReader* aOwner) : mOwner(aOwner) { }
+  explicit DecoderFactory(MediaFormatReader* aOwner)
+    : mAudio(aOwner->mAudio, TrackInfo::kAudioTrack)
+    , mVideo(aOwner->mVideo, TrackInfo::kVideoTrack)
+    , mOwner(aOwner) { }
+
   void CreateDecoder(TrackType aTrack);
   // Shutdown any decoder pending initialization.
   RefPtr<ShutdownPromise> ShutdownDecoder(TrackType aTrack)
   {
     MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack
                || aTrack == TrackInfo::kVideoTrack);
     auto& data = aTrack == TrackInfo::kAudioTrack ? mAudio : mVideo;
     data.mTokenRequest.DisconnectIfExists();
@@ -226,16 +230,23 @@ private:
     None,
     WaitForToken,
     CreateDecoder,
     WaitForInit
   };
 
   struct Data
   {
+    Data(DecoderData& aOwnerData, TrackType aTrack)
+      : mOwnerData(aOwnerData)
+      , mTrack(aTrack)
+      , mPolicy(DecoderAllocPolicy::Instance(aTrack)) { }
+    DecoderData& mOwnerData;
+    const TrackType mTrack;
+    DecoderAllocPolicy& mPolicy;
     Stage mStage = Stage::None;
     RefPtr<Token> mToken;
     RefPtr<MediaDataDecoder> mDecoder;
     MozPromiseRequestHolder<TokenPromise> mTokenRequest;
     MozPromiseRequestHolder<InitPromise> mInitRequest;
     MozPromiseRequestHolder<ShutdownPromise> mShutdownRequest;
     RefPtr<ShutdownPromise> mShutdownPromise;
   } mAudio, mVideo;