Bug 1304314. Part 2 - split the code of HasLowDecodedData() into separate functions which will be reusable. r=kikuo
authorJW Wang <jwwang@mozilla.com>
Wed, 21 Sep 2016 16:27:40 +0800
changeset 315215 2bd3bdee7d08d427b043e621d0b4d40c48a7442f
parent 315214 510ec7a9898dbedccd35f4a7b93e1af66a74ae9f
child 315216 7b8ab6891c497ae6cc0b4cf96092c9e8a99404d5
push id82104
push userihsiao@mozilla.com
push dateMon, 26 Sep 2016 11:08:56 +0000
treeherdermozilla-inbound@87aeaae19f90 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskikuo
bugs1304314
milestone52.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 1304314. Part 2 - split the code of HasLowDecodedData() into separate functions which will be reusable. r=kikuo MozReview-Commit-ID: KwNOx1uTdjK
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2313,28 +2313,37 @@ MediaDecoderStateMachine::StartMediaSink
         OwnerThread(), __func__, this,
         &MediaDecoderStateMachine::OnMediaSinkVideoComplete,
         &MediaDecoderStateMachine::OnMediaSinkVideoError));
     }
   }
 }
 
 bool
+MediaDecoderStateMachine::HasLowDecodedAudio()
+{
+  MOZ_ASSERT(OnTaskQueue());
+  return IsAudioDecoding() &&
+         GetDecodedAudioDuration() < EXHAUSTED_DATA_MARGIN_USECS;
+}
+
+bool
+MediaDecoderStateMachine::HasLowDecodedVideo()
+{
+  MOZ_ASSERT(OnTaskQueue());
+  return IsVideoDecoding() &&
+         static_cast<uint32_t>(VideoQueue().GetSize()) < LOW_VIDEO_FRAMES;
+}
+
+bool
 MediaDecoderStateMachine::HasLowDecodedData()
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(mReader->UseBufferingHeuristics());
-  // We consider ourselves low on decoded data if we're low on audio,
-  // provided we've not decoded to the end of the audio stream, or
-  // if we're low on video frames, provided
-  // we've not decoded to the end of the video stream.
-  return (IsAudioDecoding() &&
-          GetDecodedAudioDuration() < EXHAUSTED_DATA_MARGIN_USECS) ||
-         (IsVideoDecoding() &&
-          static_cast<uint32_t>(VideoQueue().GetSize()) < LOW_VIDEO_FRAMES);
+  return HasLowDecodedAudio() || HasLowDecodedVideo();
 }
 
 bool MediaDecoderStateMachine::OutOfDecodedAudio()
 {
     MOZ_ASSERT(OnTaskQueue());
     return IsAudioDecoding() && !AudioQueue().IsFinished() &&
            AudioQueue().GetSize() == 0 &&
            !mMediaSink->HasUnplayedFrames(TrackInfo::kAudioTrack);
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -380,16 +380,20 @@ protected:
   // True if our buffers of decoded video are not full, and we should
   // decode more.
   bool NeedToDecodeVideo();
 
   // True if we are low in decoded audio/video data.
   // May not be invoked when mReader->UseBufferingHeuristics() is false.
   bool HasLowDecodedData();
 
+  bool HasLowDecodedAudio();
+
+  bool HasLowDecodedVideo();
+
   bool OutOfDecodedAudio();
 
   bool OutOfDecodedVideo()
   {
     MOZ_ASSERT(OnTaskQueue());
     return IsVideoDecoding() && VideoQueue().GetSize() <= 1;
   }