Bug 945475 - clear |mVideoFrameContainer| to stop staled callbacks which give incorrect videoWidth/videoHeight. r=roc

This commit is contained in:
JW Wang 2014-03-27 07:27:01 +08:00
Родитель ce63e5f311
Коммит 6edcb8f105
1 изменённых файлов: 11 добавлений и 4 удалений

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

@ -760,9 +760,13 @@ NS_IMETHODIMP HTMLMediaElement::Load()
void HTMLMediaElement::ResetState()
{
mMediaSize = nsIntSize(-1, -1);
VideoFrameContainer* container = GetVideoFrameContainer();
if (container) {
container->Reset();
// There might be a pending MediaDecoder::PlaybackPositionChanged() which
// will overwrite |mMediaSize| in UpdateMediaSize() to give staled videoWidth
// and videoHeight. We have to call ForgetElement() here such that the staled
// callbacks won't reach us.
if (mVideoFrameContainer) {
mVideoFrameContainer->ForgetElement();
mVideoFrameContainer = nullptr;
}
}
@ -3012,7 +3016,10 @@ void HTMLMediaElement::MetadataLoaded(int aChannels,
// If this element had a video track, but consists only of an audio track now,
// delete the VideoFrameContainer. This happens when the src is changed to an
// audio only file.
if (!aHasVideo) {
if (!aHasVideo && mVideoFrameContainer) {
// call ForgetElement() such that callbacks from |mVideoFrameContainer|
// won't reach us anymore.
mVideoFrameContainer->ForgetElement();
mVideoFrameContainer = nullptr;
}
}