[WIP]
Bug 1309492 part 2 - tune up the HTMLMediaElement::GetCurrentImage so that is won't return frames produced by the blank decoder module; r?jwwang
MozReview-Commit-ID: CelDMGhzryR
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -811,25 +811,29 @@ HTMLMediaElement::SetVisible(bool aVisib
layers::Image*
HTMLMediaElement::GetCurrentImage()
{
ImageContainer* container = GetImageContainer();
if (!container) {
return nullptr;
}
+ // Only the first time this method is called should we try to block. After the
+ // first invocation, the video decoder will never be switched to blank decoder
+ // and so we should never need to block again.
+ if (mDecoder && !mHasSuspendTaint) {
+ // If element has a decoder, block and get next decoded image, otherwise use
+ // standard, non-blocking behavior.
+ mDecoder->WaitOnNextRenderedVideoFrame();
+ }
+
// Mark the decoder owned by the element as tainted so that the video decode
// won't be suspended. If the decoder is already in suspended state, this will
// resume decoding.
mHasSuspendTaint = true;
- if (mDecoder) {
- // If element has a decoder, block and get next decoded image, otherwise use
- // standard, non-blocking behavior.
- mDecoder->WaitOnNextRenderedVideoFrame();
- }
AutoLockImage lockImage(container);
return lockImage.GetImage();
}
bool
HTMLMediaElement::HasSuspendTaint() const
{
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1308,20 +1308,23 @@ void
MediaDecoder::DispatchPendingTasks()
{
mDecoderStateMachine->DispatchPendingTasks();
}
void
MediaDecoder::WaitOnNextRenderedVideoFrame()
{
- if (GetImageContainer()->HasCurrentImage()) {
- SetSuspendTaint(true);
- return;
- }
+ // We don't check if the |if (GetImageContainer()->HasCurrentImage())| and
+ // don't return early here because that this method is only called once and
+ // at the first time this method is called, the video decoder could be:
+ // (1) normal decoder: then the monitor will be notified soon at the
+ // MediaDecoderStateMachine::SuspendTaintChanged() method.
+ // (2) blank decoder: then the monitor will be notified after the resuming
+ // seek is completed.
// Image container doesn't have a valid frame. Wait for the decoder
// to produce a new frame.
using WaitForFrame = MediaDecoderStateMachine::WaitForFrame;
WaitForFrame state{ "WaitOnNextRenderedVideoFrame" };
// Dispatch the variable setting before changing the suspend taint
// that'll trigger the decoder to start up.