Bug 1402584 - only set MDSM::mDuration after metadata is loaded in MDSM::BufferedRangeUpdated(); r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Thu, 28 Sep 2017 16:13:10 +0800
changeset 671763 71adbb7dbb053cb3c8c97e3587540dd3258149ab
parent 671566 e1f660fc493bc4bf2f91b6df94bc98e8e3840c42
child 733605 e449215a02559b4f483367742f931767d1c3aca7
push id82032
push userbmo:kaku@mozilla.com
push dateThu, 28 Sep 2017 08:15:53 +0000
reviewersjwwang
bugs1402584
milestone58.0a1
Bug 1402584 - only set MDSM::mDuration after metadata is loaded in MDSM::BufferedRangeUpdated(); r?jwwang MozReview-Commit-ID: 3VVuWUXB8lL
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3047,16 +3047,22 @@ void MediaDecoderStateMachine::BufferedR
   }
 
   bool exists;
   media::TimeUnit end{ mBuffered.Ref().GetEnd(&exists) };
   if (!exists) {
     return;
   }
 
+  // We need to check mInfo.isSome() because that this method might be invoked
+  // before the metadata been read.
+  if (mInfo.isNothing() || Info().mMetadataDuration.isNothing()) {
+    return;
+  }
+
   // Use estimated duration from buffer ranges when mDuration is unknown or
   // the estimated duration is larger.
   if (mDuration.Ref().isNothing() || mDuration.Ref()->IsInfinite() ||
       end > mDuration.Ref().ref()) {
     mDuration = Some(end);
   }
 }