Bug 1185886: P2. Don't unnecessarily drain decoders when there's no frames pending. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sun, 26 Jul 2015 21:52:22 +1000
changeset 254635 6681786341a9dd54171d30ede88538cece2c3f8f
parent 254634 91de55bfe09a037364b9e4a8947e97eecc6054e1
child 254636 6a5306e6d457c2fc4a0d2450e0a0b5ba328eac0e
push id29108
push userryanvm@gmail.com
push dateMon, 27 Jul 2015 14:12:01 +0000
treeherdermozilla-central@27ae736ef960 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1185886
milestone42.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 1185886: P2. Don't unnecessarily drain decoders when there's no frames pending. r=cpearce
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -710,16 +710,17 @@ MediaFormatReader::NotifyInputExhausted(
   ScheduleUpdate(aTrack);
 }
 
 void
 MediaFormatReader::NotifyDrainComplete(TrackType aTrack)
 {
   MOZ_ASSERT(OnTaskQueue());
   auto& decoder = GetDecoderData(aTrack);
+  LOG("%s", TrackTypeToStr(aTrack));
   if (!decoder.mOutputRequested) {
     LOG("MediaFormatReader called DrainComplete() before flushing, ignoring.");
     return;
   }
   decoder.mDrainComplete = true;
   ScheduleUpdate(aTrack);
 }
 
@@ -978,16 +979,21 @@ MediaFormatReader::DrainDecoder(TrackTyp
   if (!decoder.mNeedDraining || decoder.mDraining) {
     return;
   }
   decoder.mNeedDraining = false;
   if (!decoder.mDecoder) {
     return;
   }
   decoder.mOutputRequested = true;
+  if (decoder.mNumSamplesInput == decoder.mNumSamplesOutput) {
+    // No frames to drain.
+    NotifyDrainComplete(aTrack);
+    return;
+  }
   decoder.mDecoder->Drain();
   decoder.mDraining = true;
   LOG("Requesting %s decoder to drain", TrackTypeToStr(aTrack));
 }
 
 void
 MediaFormatReader::Update(TrackType aTrack)
 {