Bug 785671 - nsHTMLMediaElement::mSrcStreamListener should be an nsRefPtr r=roc

This commit is contained in:
David Zbarsky 2012-08-26 19:33:56 -04:00
parent ba13045df3
commit 501d88a50c
2 changed files with 3 additions and 4 deletions

View File

@ -647,8 +647,8 @@ protected:
};
nsTArray<OutputMediaStream> mOutputStreams;
// Holds a reference to the MediaStreamListener attached to mSrcStream. STRONG!
StreamListener* mSrcStreamListener;
// Holds a reference to the MediaStreamListener attached to mSrcStream.
nsRefPtr<StreamListener> mSrcStreamListener;
// Holds a reference to the first channel we open to the media resource.
// Once the decoder is created, control over the channel passes to the

View File

@ -2601,7 +2601,6 @@ void nsHTMLMediaElement::SetupSrcMediaStreamPlayback()
// XXX if we ever support capturing the output of a media element which is
// playing a stream, we'll need to add a CombineWithPrincipal call here.
mSrcStreamListener = new StreamListener(this);
NS_ADDREF(mSrcStreamListener);
GetSrcMediaStream()->AddListener(mSrcStreamListener);
if (mPaused) {
GetSrcMediaStream()->ChangeExplicitBlockerCount(1);
@ -2627,7 +2626,7 @@ void nsHTMLMediaElement::EndSrcMediaStreamPlayback()
GetSrcMediaStream()->RemoveListener(mSrcStreamListener);
// Kill its reference to this element
mSrcStreamListener->Forget();
NS_RELEASE(mSrcStreamListener); // sets to null
mSrcStreamListener = nullptr;
GetSrcMediaStream()->RemoveAudioOutput(this);
VideoFrameContainer* container = GetVideoFrameContainer();
if (container) {