Bug 1321235 - Let ended MediaStreamTracks be removable. r?jesup draft
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 01 Dec 2016 19:35:48 +0100
changeset 446653 49e98ff2960f1781bcd39038dfc89d72e7975e19
parent 446652 ec315fd287f4b55afd814fb2d2c8b8b47f32699c
child 538832 887713beef6a47c3bf2b44ea5f59912d77ccb696
push id37845
push userbmo:pehrson@telenordigital.com
push dateThu, 01 Dec 2016 18:36:30 +0000
reviewersjesup
bugs1321235
milestone53.0a1
Bug 1321235 - Let ended MediaStreamTracks be removable. r?jesup MozReview-Commit-ID: A3V3SY4L3HL
dom/media/DOMMediaStream.cpp
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -639,29 +639,28 @@ DOMMediaStream::RemoveTrack(MediaStreamT
                        this, &aTrack, aTrack.mOwningStream.get(), aTrack.mTrackID));
 
   RefPtr<TrackPort> toRemove = FindPlaybackTrackPort(aTrack);
   if (!toRemove) {
     LOG(LogLevel::Debug, ("DOMMediaStream %p does not contain track %p", this, &aTrack));
     return;
   }
 
+  DebugOnly<bool> removed = mTracks.RemoveElement(toRemove);
+  NS_ASSERTION(removed, "If there's a track port we should be able to remove it");
+
   // If the track comes from a TRACK_ANY input port (i.e., mOwnedPort), we need
   // to block it in the port. Doing this for a locked track is still OK as it
   // will first block the track, then destroy the port. Both cause the track to
   // end.
   // If the track has already ended, it's input port might be gone, so in those
   // cases blocking the underlying track should be avoided.
   if (!aTrack.Ended()) {
     BlockPlaybackTrack(toRemove);
-
-    bool removed = mTracks.RemoveElement(toRemove);
-    if (removed) {
-      NotifyTrackRemoved(&aTrack);
-    }
+    NotifyTrackRemoved(&aTrack);
   }
 
   LOG(LogLevel::Debug, ("DOMMediaStream %p Removed track %p", this, &aTrack));
 }
 
 class ClonedStreamSourceGetter :
   public MediaStreamTrackSourceGetter
 {