Bug 1321235 - Let ended MediaStreamTracks be removable. r?jesup
MozReview-Commit-ID: A3V3SY4L3HL
--- 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
{