Bug 1453127 - Clear output streams on shutdown. r=jya, a=RyanVM
☠☠ backed out by d34e9c8ef023 ☠ ☠
authorAndreas Pehrson <pehrsons@mozilla.com>
Wed, 30 May 2018 10:44:56 +0200
changeset 806014 d00df8beb17e1681adea2e8f3007af7a2cae3422
parent 806013 7e420412a88561dea30f53e6c23826018b5515db
child 806015 ca4b7fbb56dc7f8b809b37b35cb872031115fecd
push id112832
push userbballo@mozilla.com
push dateFri, 08 Jun 2018 21:11:22 +0000
reviewersjya, RyanVM
bugs1453127
milestone60.0.2
Bug 1453127 - Clear output streams on shutdown. r=jya, a=RyanVM
dom/media/MediaDecoderStateMachine.cpp
dom/media/mediasink/OutputStreamManager.cpp
dom/media/mediasink/OutputStreamManager.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3477,16 +3477,20 @@ MediaDecoderStateMachine::FinishDecodeFi
   mReader->ReadUpdatedMetadata(mInfo.ptr());
 
   EnqueueFirstFrameLoadedEvent();
 }
 
 RefPtr<ShutdownPromise>
 MediaDecoderStateMachine::BeginShutdown()
 {
+  MOZ_ASSERT(NS_IsMainThread());
+  if (mOutputStreamManager) {
+    mOutputStreamManager->Clear();
+  }
   return InvokeAsync(OwnerThread(), this, __func__,
                      &MediaDecoderStateMachine::Shutdown);
 }
 
 RefPtr<ShutdownPromise>
 MediaDecoderStateMachine::FinishShutdown()
 {
   MOZ_ASSERT(OnTaskQueue());
--- a/dom/media/mediasink/OutputStreamManager.cpp
+++ b/dom/media/mediasink/OutputStreamManager.cpp
@@ -120,16 +120,23 @@ OutputStreamManager::Remove(MediaStream*
   for (int32_t i = mStreams.Length() - 1; i >= 0; --i) {
     if (mStreams[i].Equals(aStream)) {
       mStreams.RemoveElementAt(i);
       break;
     }
   }
 }
 
+void
+OutputStreamManager::Clear()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  mStreams.Clear();
+}
+
 TrackID
 OutputStreamManager::NextAvailableTrackIDFor(MediaStream* aOutputStream) const
 {
   MOZ_ASSERT(NS_IsMainThread());
   for (const OutputStreamData& out : mStreams) {
     if (out.Equals(aOutputStream)) {
       return out.NextAvailableTrackID();
     }
--- a/dom/media/mediasink/OutputStreamManager.h
+++ b/dom/media/mediasink/OutputStreamManager.h
@@ -54,16 +54,18 @@ class OutputStreamManager {
 
 public:
   // Add the output stream to the collection.
   void Add(ProcessedMediaStream* aStream,
            TrackID aNextAvailableTrackID,
            bool aFinishWhenEnded);
   // Remove the output stream from the collection.
   void Remove(MediaStream* aStream);
+  // Clear all output streams from the collection.
+  void Clear();
   // The next TrackID that will not cause a collision in aOutputStream.
   TrackID NextAvailableTrackIDFor(MediaStream* aOutputStream) const;
   // Return true if the collection empty.
   bool IsEmpty() const
   {
     MOZ_ASSERT(NS_IsMainThread());
     return mStreams.IsEmpty();
   }