Bug 1128069: [MSE] P4. Do not adjust duration to what data we may have been seen in the past. r?jwwang draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 05 Aug 2016 16:03:01 +1000
changeset 397766 2f7e17d48ede2fb7a21a294bc5d58df51f90de2f
parent 397765 9b5cfff281909e047d89fcdeae828548d1474f84
child 397767 48268c8af35bd3ccd8a209c61d439ccae89a2bd1
push id25391
push userbmo:jyavenard@mozilla.com
push dateMon, 08 Aug 2016 09:33:44 +0000
reviewersjwwang
bugs1128069
milestone51.0a1
Bug 1128069: [MSE] P4. Do not adjust duration to what data we may have been seen in the past. r?jwwang With MediaSource, the duration is always known and exact. It is entirely possible that we have played data at some point, then removed that data and adjusted the duration. MozReview-Commit-ID: HZe2yXtQfIL
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1095,17 +1095,22 @@ void MediaDecoderStateMachine::Recompute
   } else if (mEstimatedDuration.Ref().isSome()) {
     duration = mEstimatedDuration.Ref().ref();
   } else if (mInfo.mMetadataDuration.isSome()) {
     duration = mInfo.mMetadataDuration.ref();
   } else {
     return;
   }
 
-  if (duration < mObservedDuration.Ref()) {
+  // Only adjust the duration when an explicit duration isn't set (MSE).
+  // The duration is always exactly known with MSE and there's no need to adjust
+  // it based on what may have been seen in the past; in particular as this data
+  // may no longer exist such as when the mediasource duration was reduced.
+  if (mExplicitDuration.Ref().isNothing() &&
+      duration < mObservedDuration.Ref()) {
     duration = mObservedDuration;
   }
 
   MOZ_ASSERT(duration.ToMicroseconds() >= 0);
   mDuration = Some(duration);
 }
 
 void