Bug 1274199 - remove use of FlushableTaskQueue. r=jya. draft 1274199_remove_BlankMediaDataDecoder_TaskQueue
authorJW Wang <jwwang@mozilla.com>
Thu, 19 May 2016 17:04:18 +0800
branch1274199_remove_BlankMediaDataDecoder_TaskQueue
changeset 370018 5a8877922eabf0993839b882b800304057cc57fc
parent 370017 767cac9662d01ea936191aef6963e90b19a5cde0
child 370019 ea3d57a3034577ddc1d079f50094ca4ad46f40bb
child 724568 0ee47a7bdf08a99cc8e8657967e68262fb7c25fe
push id18977
push userjwwang@mozilla.com
push dateTue, 24 May 2016 03:49:46 +0000
reviewersjya
bugs1274199
milestone49.0a1
Bug 1274199 - remove use of FlushableTaskQueue. r=jya. MozReview-Commit-ID: J9BHEuF6CPJ
dom/media/platforms/agnostic/BlankDecoderModule.cpp
--- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp
@@ -20,90 +20,62 @@ namespace mozilla {
 
 // Decoder that uses a passed in object's Create function to create blank
 // MediaData objects.
 template<class BlankMediaDataCreator>
 class BlankMediaDataDecoder : public MediaDataDecoder {
 public:
 
   BlankMediaDataDecoder(BlankMediaDataCreator* aCreator,
-                        FlushableTaskQueue* aTaskQueue,
                         MediaDataDecoderCallback* aCallback,
                         TrackInfo::TrackType aType)
     : mCreator(aCreator)
-    , mTaskQueue(aTaskQueue)
     , mCallback(aCallback)
     , mType(aType)
   {
   }
 
   RefPtr<InitPromise> Init() override {
     return InitPromise::CreateAndResolve(mType, __func__);
   }
 
   nsresult Shutdown() override {
     return NS_OK;
   }
 
-  class OutputEvent : public Runnable {
-  public:
-    OutputEvent(MediaRawData* aSample,
-                MediaDataDecoderCallback* aCallback,
-                BlankMediaDataCreator* aCreator)
-      : mSample(aSample)
-      , mCreator(aCreator)
-      , mCallback(aCallback)
-    {
-    }
-    NS_IMETHOD Run() override
-    {
-      RefPtr<MediaData> data =
-        mCreator->Create(media::TimeUnit::FromMicroseconds(mSample->mTime),
-                         media::TimeUnit::FromMicroseconds(mSample->mDuration),
-                         mSample->mOffset);
-      if (!data) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
-      mCallback->Output(data);
-      return NS_OK;
-    }
-  private:
-    RefPtr<MediaRawData> mSample;
-    BlankMediaDataCreator* mCreator;
-    MediaDataDecoderCallback* mCallback;
-  };
-
   nsresult Input(MediaRawData* aSample) override
   {
-    // The MediaDataDecoder must delete the sample when we're finished
-    // with it, so the OutputEvent stores it in an nsAutoPtr and deletes
-    // it once it's run.
-    RefPtr<nsIRunnable> r(new OutputEvent(aSample, mCallback, mCreator));
-    mTaskQueue->Dispatch(r.forget());
+    RefPtr<MediaData> data =
+      mCreator->Create(media::TimeUnit::FromMicroseconds(aSample->mTime),
+                       media::TimeUnit::FromMicroseconds(aSample->mDuration),
+                       aSample->mOffset);
+    if (!data) {
+      mCallback->Error();
+    } else {
+      mCallback->Output(data);
+    }
     return NS_OK;
   }
 
   nsresult Flush() override {
-    mTaskQueue->Flush();
     return NS_OK;
   }
 
   nsresult Drain() override {
     mCallback->DrainComplete();
     return NS_OK;
   }
 
   const char* GetDescriptionName() const override
   {
     return "blank media data decoder";
   }
 
 private:
   nsAutoPtr<BlankMediaDataCreator> mCreator;
-  RefPtr<FlushableTaskQueue> mTaskQueue;
   MediaDataDecoderCallback* mCallback;
   TrackInfo::TrackType mType;
 };
 
 class BlankVideoDataCreator {
 public:
   BlankVideoDataCreator(uint32_t aFrameWidth,
                         uint32_t aFrameHeight,
@@ -231,34 +203,32 @@ public:
                      layers::ImageContainer* aImageContainer,
                      FlushableTaskQueue* aVideoTaskQueue,
                      MediaDataDecoderCallback* aCallback,
                      DecoderDoctorDiagnostics* aDiagnostics) override {
     BlankVideoDataCreator* creator = new BlankVideoDataCreator(
       aConfig.mDisplay.width, aConfig.mDisplay.height, aImageContainer);
     RefPtr<MediaDataDecoder> decoder =
       new BlankMediaDataDecoder<BlankVideoDataCreator>(creator,
-                                                       aVideoTaskQueue,
                                                        aCallback,
                                                        TrackInfo::kVideoTrack);
     return decoder.forget();
   }
 
   // Decode thread.
   already_AddRefed<MediaDataDecoder>
   CreateAudioDecoder(const AudioInfo& aConfig,
                      FlushableTaskQueue* aAudioTaskQueue,
                      MediaDataDecoderCallback* aCallback,
                      DecoderDoctorDiagnostics* aDiagnostics) override {
     BlankAudioDataCreator* creator = new BlankAudioDataCreator(
       aConfig.mChannels, aConfig.mRate);
 
     RefPtr<MediaDataDecoder> decoder =
       new BlankMediaDataDecoder<BlankAudioDataCreator>(creator,
-                                                       aAudioTaskQueue,
                                                        aCallback,
                                                        TrackInfo::kAudioTrack);
     return decoder.forget();
   }
 
   bool
   SupportsMimeType(const nsACString& aMimeType,
                    DecoderDoctorDiagnostics* aDiagnostics) const override