Bug 1389304 - Don't update duration to negative buffer end - r?jya draft
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 15 Aug 2017 17:58:27 +1200
changeset 646357 fad787e134e08a87278a2209e98d58d771b80533
parent 646265 b95b1638db48fc3d450b95b98da6bcd2f9326d2f
child 726209 50710f51b568a993405aae94504d728f7d696b92
push id74085
push usergsquelart@mozilla.com
push dateTue, 15 Aug 2017 06:00:26 +0000
reviewersjya
bugs1389304
milestone57.0a1
Bug 1389304 - Don't update duration to negative buffer end - r?jya MozReview-Commit-ID: 5rbbJRk62tO
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3134,22 +3134,22 @@ void MediaDecoderStateMachine::BufferedR
   // 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.
   if (mBuffered.Ref().IsInvalid()) {
     return;
   }
 
   bool exists;
   media::TimeUnit end{ mBuffered.Ref().GetEnd(&exists) };
-  if (!exists) {
+  if (!exists || !end.IsPositive()) {
     return;
   }
 
   // Use estimated duration from buffer ranges when mDuration is unknown or
-  // the estimated duration is larger.
+  // the estimated duration is larger (and positive).
   if (mDuration.Ref().isNothing() || mDuration.Ref()->IsInfinite() ||
       end > mDuration.Ref().ref()) {
     mDuration = Some(end);
   }
 }
 
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::Seek(const SeekTarget& aTarget)