Bug 1402584 - only set MDSM::mDuration after metadata is loaded in MDSM::BufferedRangeUpdated(); r?jwwang
MozReview-Commit-ID: 3VVuWUXB8lL
--- 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);
}
}