Bug 1309516 part 9 - make sure that MDSM::mDuration is always assigned once we have meatadata; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Tue, 01 Nov 2016 17:10:03 +0800
changeset 441575 9e71897e8cc51bb802a01ef6bd3709b9539be441
parent 441574 25d91eb128bc173839d3022987b192b39cb21323
child 537578 bb1ac5d0bea25cacfaf2e64f1415ea5db667614d
push id36449
push userbmo:kaku@mozilla.com
push dateSat, 19 Nov 2016 07:05:35 +0000
reviewersjwwang
bugs1309516
milestone53.0a1
Bug 1309516 part 9 - make sure that MDSM::mDuration is always assigned once we have meatadata; r?jwwang MozReview-Commit-ID: KF7J1XGo2MD
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1254,16 +1254,21 @@ DecodeMetadataState::OnMetadataRead(Meta
     mMaster->RecomputeDuration();
   } else if (Info().mUnadjustedMetadataEndTime.isSome()) {
     const TimeUnit unadjusted = Info().mUnadjustedMetadataEndTime.ref();
     const TimeUnit adjustment = Info().mStartTime;
     mMaster->mInfo->mMetadataDuration.emplace(unadjusted - adjustment);
     mMaster->RecomputeDuration();
   }
 
+  // If we don't know the duration by this point, we assume infinity, per spec.
+  if (mMaster->mDuration.Ref().isNothing()) {
+    mMaster->mDuration = Some(TimeUnit::FromInfinity());
+  }
+
   if (mMaster->HasVideo()) {
     SLOG("Video decode isAsync=%d HWAccel=%d videoQueueSize=%d",
          Reader()->IsAsync(),
          Reader()->VideoIsHardwareAccelerated(),
          mMaster->GetAmpleVideoFrames());
   }
 
   MOZ_ASSERT(mMaster->mDuration.Ref().isSome());
@@ -2758,21 +2763,16 @@ void
 MediaDecoderStateMachine::FinishDecodeFirstFrame()
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(!mSentFirstFrameLoadedEvent);
   DECODER_LOG("FinishDecodeFirstFrame");
 
   mMediaSink->Redraw(Info().mVideo);
 
-  // If we don't know the duration by this point, we assume infinity, per spec.
-  if (mDuration.Ref().isNothing()) {
-    mDuration = Some(TimeUnit::FromInfinity());
-  }
-
   DECODER_LOG("Media duration %lld, "
               "transportSeekable=%d, mediaSeekable=%d",
               Duration().ToMicroseconds(), mResource->IsTransportSeekable(), mMediaSeekable);
 
   // Get potentially updated metadata
   mReader->ReadUpdatedMetadata(mInfo.ptr());
 
   EnqueueFirstFrameLoadedEvent();