From 6ce3e3224ccc73509c297ccb1ff100316e657ae3 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Wed, 16 Aug 2017 15:33:58 +0800 Subject: [PATCH] Bug 1390443. P1 - don't change nextFrameStatus when MDSM reaches the end of playback. r=cpearce Instead, MediaDecoder::NextFrameStatus() checks IsEnded() and returns NEXT_FRAME_UNAVAILABLE to ensure we have HAVE_CURRENT_DATA when playback is ended on the main thread. This will fix the timing issue (comment 0) which causes 'waiting' to fire. MozReview-Commit-ID: 7O21x2q0lb8 --HG-- extra : rebase_source : bbd898edfb5f4a47a5062dd2bc916c911caf0c8e extra : intermediate-source : 2b3e413db02a7aad00d13fdf274b346bccafc414 extra : source : 6f60fad11b65e75b456e128f8414fe2ea545455f --- dom/html/HTMLMediaElement.cpp | 8 -------- dom/media/MediaDecoder.h | 3 ++- dom/media/MediaDecoderStateMachine.cpp | 3 --- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index b3155c4caed1..11f9a2b78633 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -5824,14 +5824,6 @@ HTMLMediaElement::UpdateReadyStateInternal() return; } - if (mDecoder && !mDecoder->IsEnded() && - !mDecoder->GetResource()->IsExpectingMoreData()) { - LOG(LogLevel::Debug, ("MediaElement %p UpdateReadyStateInternal() " - "Decoder fetched all data for media resource", this)); - ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA); - return; - } - if (nextFrameStatus != MediaDecoderOwner::NEXT_FRAME_AVAILABLE) { LOG(LogLevel::Debug, ("MediaElement %p UpdateReadyStateInternal() " "Next frame not available", this)); diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index 311eb7dfe275..61a645ae1d99 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -400,8 +400,9 @@ private: virtual MediaDecoderOwner::NextFrameStatus NextFrameStatus() { - return mNextFrameStatus; + return !IsEnded() ? mNextFrameStatus : MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE; } + virtual MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus(); // Returns a string describing the state of the media player internal diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 05fab84b6771..4c8ba3681371 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -2006,9 +2006,6 @@ public: } mMaster->UpdatePlaybackPosition(clockTime); - // Ensure readyState is updated before firing the 'ended' event. - mMaster->UpdateNextFrameStatus(MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE); - mMaster->mOnPlaybackEvent.Notify(MediaEventType::PlaybackEnded); mSentPlaybackEndedEvent = true;