Bug 1352319. P7 - use TimeUnit in UpdatePlaybackPositionInternal(). r=kaku
authorJW Wang <jwwang@mozilla.com>
Tue, 28 Mar 2017 15:57:38 +0800
changeset 350637 2534fc738fc679cc72d6bd1fa61c939cf61480db
parent 350636 67b7c5be82cf44d88155bea9527d644b5a167544
child 350638 75972bacb5cfe0d653084bf72aa81e3085de1269
push id39891
push userjwwang@mozilla.com
push dateFri, 31 Mar 2017 09:19:40 +0000
treeherderautoland@5ee60477d72f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1352319
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1352319. P7 - use TimeUnit in UpdatePlaybackPositionInternal(). r=kaku MozReview-Commit-ID: ASzjKhHlhVA
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -961,18 +961,17 @@ public:
       Reader()->SetVideoBlankDecode(false);
     }
 
     // Don't stop playback for a video-only seek since audio is playing.
     if (!mSeekJob.mTarget->IsVideoOnly()) {
       mMaster->StopPlayback();
     }
 
-    mMaster->UpdatePlaybackPositionInternal(
-      mSeekJob.mTarget->GetTime().ToMicroseconds());
+    mMaster->UpdatePlaybackPositionInternal(mSeekJob.mTarget->GetTime());
 
     if (aVisibility == EventVisibility::Observable) {
       mMaster->mOnPlaybackEvent.Notify(MediaEventType::SeekStarted);
       // We want dormant actions to be transparent to the user.
       // So we only notify the change when the seek request is from the user.
       mMaster->UpdateNextFrameStatus(
         MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING);
     }
@@ -2410,17 +2409,18 @@ SeekingState::SeekCompleted()
     mMaster->FinishDecodeFirstFrame();
   }
 
   // Ensure timestamps are up to date.
   if (!target.IsVideoOnly()) {
     // Don't update playback position for video-only seek.
     // Otherwise we might have |newCurrentTime > mMediaSink->GetPosition()|
     // and fail the assertion in GetClock() since we didn't stop MediaSink.
-    mMaster->UpdatePlaybackPositionInternal(newCurrentTime);
+    mMaster->UpdatePlaybackPositionInternal(
+      TimeUnit::FromMicroseconds(newCurrentTime));
   }
 
   // Dispatch an event so that the UI can change in response to the end of
   // video-only seek
   if (target.IsVideoOnly()) {
     mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
   }
 
@@ -2908,31 +2908,32 @@ void MediaDecoderStateMachine::MaybeStar
   StartMediaSink();
 
   if (!IsPlaying()) {
     mMediaSink->SetPlaying(true);
     MOZ_ASSERT(IsPlaying());
   }
 }
 
-void MediaDecoderStateMachine::UpdatePlaybackPositionInternal(int64_t aTime)
+void
+MediaDecoderStateMachine::UpdatePlaybackPositionInternal(const TimeUnit& aTime)
 {
   MOZ_ASSERT(OnTaskQueue());
-  LOGV("UpdatePlaybackPositionInternal(%" PRId64 ")", aTime);
-
-  mCurrentPosition = aTime;
+  LOGV("UpdatePlaybackPositionInternal(%" PRId64 ")", aTime.ToMicroseconds());
+
+  mCurrentPosition = aTime.ToMicroseconds();
   NS_ASSERTION(mCurrentPosition >= 0, "CurrentTime should be positive!");
   mObservedDuration = std::max(mObservedDuration.Ref(),
                                TimeUnit::FromMicroseconds(mCurrentPosition.Ref()));
 }
 
 void MediaDecoderStateMachine::UpdatePlaybackPosition(int64_t aTime)
 {
   MOZ_ASSERT(OnTaskQueue());
-  UpdatePlaybackPositionInternal(aTime);
+  UpdatePlaybackPositionInternal(TimeUnit::FromMicroseconds(aTime));
 
   bool fragmentEnded =
     mFragmentEndTime >= 0 && GetMediaTime() >= mFragmentEndTime;
   mMetadataManager.DispatchMetadataIfNeeded(TimeUnit::FromMicroseconds(aTime));
 
   if (fragmentEnded) {
     StopPlayback();
   }
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -375,17 +375,17 @@ protected:
   int64_t GetClock(TimeStamp* aTimeStamp = nullptr) const;
 
   void SetStartTime(int64_t aStartTimeUsecs);
 
   // Update only the state machine's current playback position (and duration,
   // if unknown).  Does not update the playback position on the decoder or
   // media element -- use UpdatePlaybackPosition for that.  Called on the state
   // machine thread, caller must hold the decoder lock.
-  void UpdatePlaybackPositionInternal(int64_t aTime);
+  void UpdatePlaybackPositionInternal(const media::TimeUnit& aTime);
 
   // Update playback position and trigger next update by default time period.
   // Called on the state machine thread.
   void UpdatePlaybackPositionPeriodically();
 
   media::MediaSink* CreateAudioSink();
 
   // Always create mediasink which contains an AudioSink or StreamSink inside.