From 20c6e5d1e0876b5c3ad57c0f4b2581598d76f527 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Tue, 23 Aug 2016 18:08:19 +0200 Subject: [PATCH] Bug 1259788 - Remove direct track listeners from TrackUnionStream before inputs are removed. r=jesup MozReview-Commit-ID: DTHF2pHEFSt --HG-- extra : rebase_source : feddfc8ddbae33b2c97d0009b2a648ca71b33bbe --- dom/media/TrackUnionStream.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dom/media/TrackUnionStream.cpp b/dom/media/TrackUnionStream.cpp index 88ae792b3c5f..b6f3b55bcc99 100644 --- a/dom/media/TrackUnionStream.cpp +++ b/dom/media/TrackUnionStream.cpp @@ -58,6 +58,10 @@ TrackUnionStream::TrackUnionStream() : if (mTrackMap[i].mInputPort == aPort) { STREAM_LOG(LogLevel::Debug, ("TrackUnionStream %p removing trackmap entry %d", this, i)); EndTrack(i); + for (auto listener : mTrackMap[i].mOwnedDirectListeners) { + // Remove listeners while the entry still exists. + RemoveDirectTrackListenerImpl(listener, mTrackMap[i].mOutputTrackID); + } mTrackMap.RemoveElementAt(i); } } @@ -130,6 +134,10 @@ TrackUnionStream::TrackUnionStream() : allFinished = false; } if (!mappedTracksWithMatchingInputTracks[i]) { + for (auto listener : mTrackMap[i].mOwnedDirectListeners) { + // Remove listeners while the entry still exists. + RemoveDirectTrackListenerImpl(listener, mTrackMap[i].mOutputTrackID); + } mTrackMap.RemoveElementAt(i); } }