Bug 1218311 - Port the fix of bug 1193614 to VideoSink. r=cpearce. f=dglastonbury.
☠☠ backed out by d84d28b5c9be ☠ ☠
authorJW Wang <jwwang@mozilla.com>
Tue, 03 Nov 2015 11:36:24 +0800
changeset 270881 9ce253c10b9a
parent 270880 1a41401462ca
child 270882 3a49120fe460
push id67492
push userjwwang@mozilla.com
push date2015-11-03 07:17 +0000
treeherdermozilla-inbound@9ce253c10b9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1218311, 1193614
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1218311 - Port the fix of bug 1193614 to VideoSink. r=cpearce. f=dglastonbury.
dom/media/MediaDecoderStateMachine.cpp
dom/media/mediasink/VideoSink.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -885,29 +885,16 @@ MediaDecoderStateMachine::OnVideoDecoded
       Push(video, MediaData::VIDEO_DATA);
       if (MaybeFinishDecodeFirstFrame()) {
         return;
       }
       if (mIsVideoPrerolling && DonePrerollingVideo()) {
         StopPrerollingVideo();
       }
 
-      // Schedule the state machine to send stream data as soon as possible if
-      // the VideoQueue() is empty or contains one frame before the Push().
-      //
-      // The state machine threads requires a frame in VideoQueue() that is `in
-      // the future` to gather precise timing information. The head of
-      // VideoQueue() is always `in the past`.
-      //
-      // Schedule the state machine as soon as possible to render the video
-      // frame or delay the state machine thread accurately.
-      if (VideoQueue().GetSize() <= 2) {
-        ScheduleStateMachine();
-      }
-
       // For non async readers, if the requested video sample was slow to
       // arrive, increase the amount of audio we buffer to ensure that we
       // don't run out of audio. This is unnecessary for async readers,
       // since they decode audio and video on different threads so they
       // are unlikely to run out of decoded audio.
       if (mReader->IsAsync()) {
         return;
       }
--- a/dom/media/mediasink/VideoSink.cpp
+++ b/dom/media/mediasink/VideoSink.cpp
@@ -216,19 +216,25 @@ VideoSink::Shutdown()
 
   mAudioSink->Shutdown();
 }
 
 void
 VideoSink::OnVideoQueueEvent()
 {
   AssertOwnerThread();
-  // Listen to push event, VideoSink should try rendering ASAP if first frame
-  // arrives but update scheduler is not triggered yet.
-  TryUpdateRenderedVideoFrames();
+
+  // The video queue is empty or contains only one frame before Push() which
+  // means we are slow in video decoding and don't have enough information to
+  // schedule next render loop accurately (default timeout is 40ms). We need
+  // to render incoming frames immediately so render loop can be scheduled
+  // again accurately.
+  if (mAudioSink->IsPlaying() && VideoQueue().GetSize() <= 2) {
+    UpdateRenderedVideoFrames();
+  }
 }
 
 void
 VideoSink::Redraw()
 {
   AssertOwnerThread();
   RenderVideoFrames(1);
 }