Bug 1352319. P7 - use TimeUnit in UpdatePlaybackPositionInternal(). draft
authorJW Wang <jwwang@mozilla.com>
Tue, 28 Mar 2017 15:57:38 +0800
changeset 554256 af1d04fc198e61e2d0bef5899d546af90bbee6ce
parent 554255 f52044128c554b7f491f183731c35d047d5afbd9
child 554257 a69e913e906c619f0f829b7829df21ee7d38eb77
push id51883
push userjwwang@mozilla.com
push dateFri, 31 Mar 2017 09:16:07 +0000
bugs1352319
milestone55.0a1
Bug 1352319. P7 - use TimeUnit in UpdatePlaybackPositionInternal(). 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.