Bug 1203449 - Remove OutputStreamListener from DecodedStream.cpp. r=roc.
authorJW Wang <jwwang@mozilla.com>
Mon, 14 Sep 2015 10:43:27 +0800
changeset 294861 4496829ff993e1ff864b930eac75e88a6fa64ea8
parent 294860 4f506110d1af514bee46fddcaeae9c63153985c1
child 294862 a92e195a3362fa097b6fb8842b44de941e8f333c
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1203449
milestone43.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 1203449 - Remove OutputStreamListener from DecodedStream.cpp. r=roc.
dom/media/mediasink/DecodedStream.cpp
dom/media/mediasink/DecodedStream.h
--- a/dom/media/mediasink/DecodedStream.cpp
+++ b/dom/media/mediasink/DecodedStream.cpp
@@ -188,67 +188,30 @@ void
 DecodedStreamData::SetPlaying(bool aPlaying)
 {
   if (mPlaying != aPlaying) {
     mPlaying = aPlaying;
     UpdateStreamBlocking(mStream, !mPlaying);
   }
 }
 
-class OutputStreamListener : public MediaStreamListener {
-  typedef MediaStreamListener::MediaStreamGraphEvent MediaStreamGraphEvent;
-public:
-  explicit OutputStreamListener(OutputStreamData* aOwner) : mOwner(aOwner) {}
-
-  void NotifyEvent(MediaStreamGraph* aGraph, MediaStreamGraphEvent event) override
-  {
-    if (event == EVENT_FINISHED) {
-      nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(
-        this, &OutputStreamListener::DoNotifyFinished);
-      aGraph->DispatchToMainThreadAfterStreamStateUpdate(r.forget());
-    }
-  }
-
-  void Forget()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-    mOwner = nullptr;
-  }
-
-private:
-  void DoNotifyFinished()
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-    if (mOwner) {
-      // Remove the finished stream so it won't block the decoded stream.
-      mOwner->Remove();
-    }
-  }
-
-  // Main thread only
-  OutputStreamData* mOwner;
-};
-
 OutputStreamData::~OutputStreamData()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  mListener->Forget();
   // Break the connection to the input stream if necessary.
   if (mPort) {
     mPort->Destroy();
   }
 }
 
 void
 OutputStreamData::Init(OutputStreamManager* aOwner, ProcessedMediaStream* aStream)
 {
   mOwner = aOwner;
   mStream = aStream;
-  mListener = new OutputStreamListener(this);
-  aStream->AddListener(mListener);
 }
 
 void
 OutputStreamData::Connect(MediaStream* aStream)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mPort, "Already connected?");
   MOZ_ASSERT(!mStream->IsDestroyed(), "Can't connect a destroyed stream.");
@@ -277,23 +240,16 @@ OutputStreamData::Disconnect()
     mPort = nullptr;
   }
   // Block the stream again. It will be unlocked when connecting
   // to the input stream.
   mStream->ChangeExplicitBlockerCount(1);
   return true;
 }
 
-void
-OutputStreamData::Remove()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  mOwner->Remove(mStream);
-}
-
 MediaStreamGraph*
 OutputStreamData::Graph() const
 {
   return mStream->Graph();
 }
 
 void
 OutputStreamManager::Add(ProcessedMediaStream* aStream, bool aFinishWhenEnded)
--- a/dom/media/mediasink/DecodedStream.h
+++ b/dom/media/mediasink/DecodedStream.h
@@ -21,55 +21,46 @@
 namespace mozilla {
 
 class DecodedStream;
 class DecodedStreamData;
 class MediaData;
 class MediaInputPort;
 class MediaStream;
 class MediaStreamGraph;
-class OutputStreamListener;
 class OutputStreamManager;
 class ProcessedMediaStream;
 class TimeStamp;
 
 template <class T> class MediaQueue;
 
-namespace layers {
-class Image;
-} // namespace layers
-
 class OutputStreamData {
 public:
   ~OutputStreamData();
   void Init(OutputStreamManager* aOwner, ProcessedMediaStream* aStream);
 
   // Connect mStream to the input stream.
   void Connect(MediaStream* aStream);
   // Disconnect mStream from its input stream.
   // Return false is mStream is already destroyed, otherwise true.
   bool Disconnect();
-  // Called by OutputStreamListener to remove self from the output streams
-  // managed by OutputStreamManager.
-  void Remove();
   // Return true if aStream points to the same object as mStream.
   // Used by OutputStreamManager to remove an output stream.
   bool Equals(MediaStream* aStream)
   {
     return mStream == aStream;
   }
   // Return the graph mStream belongs to.
   MediaStreamGraph* Graph() const;
 
 private:
   OutputStreamManager* mOwner;
   nsRefPtr<ProcessedMediaStream> mStream;
   // mPort connects our mStream to an input stream.
   nsRefPtr<MediaInputPort> mPort;
-  nsRefPtr<OutputStreamListener> mListener;
 };
 
 class OutputStreamManager {
 public:
   // Add the output stream to the collection.
   void Add(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
   // Remove the output stream from the collection.
   void Remove(MediaStream* aStream);