Bug 1115505 - Keep decoding to ensure the stream is initialized in the decode-to-stream case. r=roc, a=sledru
authorJW Wang <jwwang@mozilla.com>
Thu, 25 Dec 2014 01:26:00 +0100
changeset 242868 4d3d7478ffa4
parent 242867 5ac62d0df17e
child 242869 5fba52895751
push id4323
push userryanvm@gmail.com
push date2015-01-14 15:46 +0000
treeherdermozilla-beta@19e248751a1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, sledru
bugs1115505
milestone36.0
Bug 1115505 - Keep decoding to ensure the stream is initialized in the decode-to-stream case. r=roc, a=sledru
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -532,16 +532,23 @@ bool MediaDecoderStateMachine::HaveEnoug
       GetDecodedAudioDuration() < aAmpleAudioUSecs) {
     return false;
   }
   if (!mAudioCaptured) {
     return true;
   }
 
   DecodedStreamData* stream = mDecoder->GetDecodedStream();
+
+  // Since stream is initialized in SendStreamData() which is called when
+  // audio/video samples are received, we need to keep decoding to ensure
+  // the stream is initialized.
+  if (stream && !stream->mStreamInitialized) {
+    return false;
+  }
   if (stream && stream->mStreamInitialized && !stream->mHaveSentFinishAudio) {
     if (!stream->mStream->HaveEnoughBuffered(TRACK_AUDIO)) {
       return false;
     }
     stream->mStream->DispatchWhenNotEnoughBuffered(TRACK_AUDIO,
         GetStateMachineThread(), GetWakeDecoderRunnable());
   }
 
@@ -552,16 +559,21 @@ bool MediaDecoderStateMachine::HaveEnoug
 {
   AssertCurrentThreadInMonitor();
 
   if (static_cast<uint32_t>(VideoQueue().GetSize()) < mAmpleVideoFrames * mPlaybackRate) {
     return false;
   }
 
   DecodedStreamData* stream = mDecoder->GetDecodedStream();
+
+  if (stream && !stream->mStreamInitialized) {
+    return false;
+  }
+
   if (stream && stream->mStreamInitialized && !stream->mHaveSentFinishVideo) {
     if (!stream->mStream->HaveEnoughBuffered(TRACK_VIDEO)) {
       return false;
     }
     stream->mStream->DispatchWhenNotEnoughBuffered(TRACK_VIDEO,
         GetStateMachineThread(), GetWakeDecoderRunnable());
   }