Bug 1175768 - Make the logic in MDSM::NotifyDataArrived apply to mObservedDuration. r=jya
authorBobby Holley <bobbyholley@gmail.com>
Tue, 16 Jun 2015 16:36:42 -0700
changeset 268586 b043b3ec9ccb920841db14879383aa20eecc73b7
parent 268585 40a894ed5740d3e0aa8e52c8a1053598d53f4cb7
child 268587 0810020721e74b2915773fbfb3dd5f80f3f6a217
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1175768
milestone41.0a1
Bug 1175768 - Make the logic in MDSM::NotifyDataArrived apply to mObservedDuration. r=jya With this change, we don't need to condition this work on infinite streams.
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1641,36 +1641,28 @@ void MediaDecoderStateMachine::Logically
 
 void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer,
                                                      uint32_t aLength,
                                                      int64_t aOffset)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
 
-  // While playing an unseekable stream of unknown duration, mDuration is
-  // updated (in AdvanceFrame()) as we play. But if data is being downloaded
-  // faster than played, mDuration won't reflect the end of playable data
+  // While playing an unseekable stream of unknown duration, mObservedDuration
+  // is updated (in AdvanceFrame()) as we play. But if data is being downloaded
+  // faster than played, mObserved won't reflect the end of playable data
   // since we haven't played the frame at the end of buffered data. So update
-  // mDuration here as new data is downloaded to prevent such a lag.
-  //
-  // Make sure to only do this if we have a start time, otherwise the reader
-  // doesn't know how to compute GetBuffered.
-  if (!mDecoder->IsInfinite() || !HaveStartTime())
-  {
-    return;
-  }
-
+  // mObservedDuration here as new data is downloaded to prevent such a lag.
   media::TimeIntervals buffered{mDecoder->GetBuffered()};
   if (!buffered.IsInvalid()) {
     bool exists;
     media::TimeUnit end{buffered.GetEnd(&exists)};
     if (exists) {
       ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-      mDuration = Some(std::max<TimeUnit>(Duration(), end));
+      mObservedDuration = std::max(mObservedDuration.Ref(), end);
     }
   }
 }
 
 nsRefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::Seek(SeekTarget aTarget)
 {
   MOZ_ASSERT(OnTaskQueue());