Bug 1321235 - Let ended MediaStreamTracks be removable. r=jesup
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 01 Dec 2016 19:35:48 +0100
changeset 325108 eea552a9e16285b98c5971e7a8a7c141a55477d4
parent 325107 7f0eb04ee1d58b0f28085bea908ad5a9425e85c2
child 325109 82cd79862bab05ae8afb3dec503c4d99c7dd8853
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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
 {