Bug 1077274: Clean up tracklists r=jib

This commit is contained in:
Randell Jesup 2014-10-03 17:29:29 -04:00
Родитель c0f03905c5
Коммит 8046f925d7
4 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -2843,6 +2843,8 @@ void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream)
GetSrcMediaStream()->AddVideoOutput(container);
}
// Note: we must call DisconnectTrackListListeners(...) before dropping
// mSrcStream
mSrcStream->ConstructMediaTracks(AudioTracks(), VideoTracks());
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
@ -2859,6 +2861,8 @@ void HTMLMediaElement::EndSrcMediaStreamPlayback()
if (stream) {
stream->RemoveListener(mSrcStreamListener);
}
mSrcStream->DisconnectTrackListListeners(AudioTracks(), VideoTracks());
// Kill its reference to this element
mSrcStreamListener->Forget();
mSrcStreamListener = nullptr;

Просмотреть файл

@ -452,6 +452,19 @@ DOMMediaStream::ConstructMediaTracks(AudioTrackList* aAudioTrackList,
}
}
void
DOMMediaStream::DisconnectTrackListListeners(const AudioTrackList* aAudioTrackList,
const VideoTrackList* aVideoTrackList)
{
for (auto i = mMediaTrackListListeners.Length(); i > 0; ) { // unsigned!
--i; // 0 ... Length()-1 range
if (mMediaTrackListListeners[i].mMediaTrackList == aAudioTrackList ||
mMediaTrackListListeners[i].mMediaTrackList == aVideoTrackList) {
mMediaTrackListListeners.RemoveElementAt(i);
}
}
}
void
DOMMediaStream::NotifyMediaStreamTrackCreated(MediaStreamTrack* aTrack)
{

Просмотреть файл

@ -242,6 +242,12 @@ public:
void ConstructMediaTracks(AudioTrackList* aAudioTrackList,
VideoTrackList* aVideoTrackList);
/**
* MUST call this before the AudioTrackList or VideoTrackList go away
*/
void DisconnectTrackListListeners(const AudioTrackList* aAudioTrackList,
const VideoTrackList* aVideoTrackList);
virtual void NotifyMediaStreamTrackCreated(MediaStreamTrack* aTrack);
virtual void NotifyMediaStreamTrackEnded(MediaStreamTrack* aTrack);

Просмотреть файл

@ -10,6 +10,8 @@
#include "mozilla/DOMEventTargetHelper.h"
namespace mozilla {
class DOMMediaStream;
namespace dom {
class HTMLMediaElement;
@ -28,6 +30,8 @@ class MediaTrackList;
class MediaTrackListListener
{
public:
friend class mozilla::DOMMediaStream;
explicit MediaTrackListListener(MediaTrackList* aMediaTrackList)
: mMediaTrackList(aMediaTrackList) {};