Bug 1399358 - call mDecoder->CanPlayThrough() so MDSM has a chance to exit buffering quickly. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 13 Sep 2017 12:43:33 +0800
changeset 663498 032b8b5fb3dd5424b63d59e79bf0a7c77207792a
parent 663497 0df0d53f7639b2945e45aa3c2b36bd51ab4dc1b5
child 731235 80ca965f5098b0445067f07b6235966fb8400611
push id79471
push userjwwang@mozilla.com
push dateWed, 13 Sep 2017 05:56:09 +0000
bugs1399358
milestone57.0a1
Bug 1399358 - call mDecoder->CanPlayThrough() so MDSM has a chance to exit buffering quickly. MozReview-Commit-ID: A5e3A8HV2ih
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5762,16 +5762,23 @@ HTMLMediaElement::UpdateReadyStateIntern
     // We haven't yet loaded the first frame, making us unable to determine
     // if we have enough valid data at the present stage.
     return;
   }
 
   if (nextFrameStatus == NEXT_FRAME_UNAVAILABLE_BUFFERING) {
     // Force HAVE_CURRENT_DATA when buffering.
     ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA);
+    if (mDecoder) {
+      // The side effect of CanPlayThrough() will update mCanPlayThrough of
+      // MDSM so it has a chance to exit buffering quickly.
+      // TODO: This implicit coupling is bad. Refactoring should be done
+      // to remove the side effect of CanPlayThrough().
+      mDecoder->CanPlayThrough();
+    }
     return;
   }
 
   // TextTracks must be loaded for the HAVE_ENOUGH_DATA and
   // HAVE_FUTURE_DATA.
   // So force HAVE_CURRENT_DATA if text tracks not loaded.
   if (mTextTrackManager && !mTextTrackManager->IsLoaded()) {
     ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA);