Bug 1353607. P9 - change the underlying type of mCurrentPosition to TimeUnit.
MozReview-Commit-ID: ffquOIFlp3
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -395,17 +395,17 @@ MediaDecoder::MediaDecoder(MediaDecoderO
, mIsDocumentVisible(false)
, mElementVisibility(Visibility::UNTRACKED)
, mIsElementInTree(false)
, mForcedHidden(false)
, mHasSuspendTaint(false)
, INIT_MIRROR(mStateMachineIsShutdown, true)
, INIT_MIRROR(mBuffered, TimeIntervals())
, INIT_MIRROR(mNextFrameStatus, MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE)
- , INIT_MIRROR(mCurrentPosition, 0)
+ , INIT_MIRROR(mCurrentPosition, TimeUnit::Zero())
, INIT_MIRROR(mStateMachineDuration, NullableTimeUnit())
, INIT_MIRROR(mPlaybackPosition, 0)
, INIT_MIRROR(mIsAudioDataAudible, false)
, INIT_CANONICAL(mVolume, 0.0)
, INIT_CANONICAL(mPreservesPitch, true)
, INIT_CANONICAL(mEstimatedDuration, NullableTimeUnit())
, INIT_CANONICAL(mExplicitDuration, Maybe<double>())
, INIT_CANONICAL(mPlayState, PLAY_STATE_LOADING)
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -565,17 +565,20 @@ protected:
// mCurrentPosition), so that |v.currentTime = foo; v.currentTime == foo|
// returns true without being affected by rounding errors.
double mLogicalPosition;
// The current playback position of the underlying playback infrastructure.
// This corresponds to the "current position" in HTML5.
// We allow omx subclasses to substitute an alternative current position for
// usage with the audio offload player.
- virtual int64_t CurrentPosition() { return mCurrentPosition; }
+ virtual int64_t CurrentPosition()
+ {
+ return mCurrentPosition.Ref().ToMicroseconds();
+ }
// Official duration of the media resource as observed by script.
double mDuration;
/******
* The following member variables can be accessed from any thread.
******/
@@ -757,17 +760,17 @@ protected:
// Buffered range, mirrored from the reader.
Mirror<media::TimeIntervals> mBuffered;
// NextFrameStatus, mirrored from the state machine.
Mirror<MediaDecoderOwner::NextFrameStatus> mNextFrameStatus;
// NB: Don't use mCurrentPosition directly, but rather CurrentPosition().
- Mirror<int64_t> mCurrentPosition;
+ Mirror<media::TimeUnit> mCurrentPosition;
// Duration of the media resource according to the state machine.
Mirror<media::NullableTimeUnit> mStateMachineDuration;
// Current playback position in the stream. This is (approximately)
// where we're up to playing back the stream. This is not adjusted
// during decoder seek operations, but it's updated at the end when we
// start playing back again.
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2416,17 +2416,17 @@ SeekingState::SeekCompleted()
// 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);
}
// Try to decode another frame to detect if we're at the end...
SLOG("Seek completed, mCurrentPosition=%" PRId64,
- mMaster->mCurrentPosition.Ref());
+ mMaster->mCurrentPosition.Ref().ToMicroseconds());
if (mMaster->VideoQueue().PeekFront()) {
mMaster->mMediaSink->Redraw(Info().mVideo);
mMaster->mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
}
SetState<DecodingState>();
}
@@ -2628,17 +2628,17 @@ MediaDecoderStateMachine::MediaDecoderSt
INIT_MIRROR(mSameOriginMedia, false),
INIT_MIRROR(mMediaPrincipalHandle, PRINCIPAL_HANDLE_NONE),
INIT_MIRROR(mPlaybackBytesPerSecond, 0.0),
INIT_MIRROR(mPlaybackRateReliable, true),
INIT_MIRROR(mDecoderPosition, 0),
INIT_CANONICAL(mDuration, NullableTimeUnit()),
INIT_CANONICAL(mIsShutdown, false),
INIT_CANONICAL(mNextFrameStatus, MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE),
- INIT_CANONICAL(mCurrentPosition, 0),
+ INIT_CANONICAL(mCurrentPosition, TimeUnit::Zero()),
INIT_CANONICAL(mPlaybackOffset, 0),
INIT_CANONICAL(mIsAudioDataAudible, false)
{
MOZ_COUNT_CTOR(MediaDecoderStateMachine);
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
InitVideoQueuePrefs();
@@ -2906,20 +2906,20 @@ void MediaDecoderStateMachine::MaybeStar
}
void
MediaDecoderStateMachine::UpdatePlaybackPositionInternal(const TimeUnit& aTime)
{
MOZ_ASSERT(OnTaskQueue());
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()));
+ mCurrentPosition = aTime;
+ NS_ASSERTION(mCurrentPosition.Ref() >= TimeUnit::Zero(),
+ "CurrentTime should be positive!");
+ mObservedDuration = std::max(mObservedDuration.Ref(), mCurrentPosition.Ref());
}
void
MediaDecoderStateMachine::UpdatePlaybackPosition(const TimeUnit& aTime)
{
MOZ_ASSERT(OnTaskQueue());
UpdatePlaybackPositionInternal(aTime);
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -446,17 +446,17 @@ protected:
// Returns the "media time". This is the absolute time which the media
// playback has reached. i.e. this returns values in the range
// [mStartTime, mEndTime], and mStartTime will not be 0 if the media does
// not start at 0. Note this is different than the "current playback position",
// which is in the range [0,duration].
media::TimeUnit GetMediaTime() const
{
MOZ_ASSERT(OnTaskQueue());
- return media::TimeUnit::FromMicroseconds(mCurrentPosition.Ref());
+ return mCurrentPosition;
}
// Returns an upper bound on the number of microseconds of audio that is
// decoded and playable. This is the sum of the number of usecs of audio which
// is decoded and in the reader's audio queue, and the usecs of unplayed audio
// which has been pushed to the audio hardware for playback. Note that after
// calling this, the audio hardware may play some of the audio pushed to
// hardware, so this can only be used as a upper bound. The decoder monitor
@@ -741,20 +741,20 @@ private:
// Whether we're currently in or transitioning to shutdown state.
Canonical<bool> mIsShutdown;
// The status of our next frame. Mirrored on the main thread and used to
// compute ready state.
Canonical<NextFrameStatus> mNextFrameStatus;
- // The time of the current frame in microseconds, corresponding to the "current
+ // The time of the current frame, corresponding to the "current
// playback position" in HTML5. This is referenced from 0, which is the initial
// playback position.
- Canonical<int64_t> mCurrentPosition;
+ Canonical<media::TimeUnit> mCurrentPosition;
// Current playback position in the stream in bytes.
Canonical<int64_t> mPlaybackOffset;
// Used to distinguish whether the audio is producing sound.
Canonical<bool> mIsAudioDataAudible;
public:
@@ -764,17 +764,17 @@ public:
{
return &mDuration;
}
AbstractCanonical<bool>* CanonicalIsShutdown() { return &mIsShutdown; }
AbstractCanonical<NextFrameStatus>* CanonicalNextFrameStatus()
{
return &mNextFrameStatus;
}
- AbstractCanonical<int64_t>* CanonicalCurrentPosition()
+ AbstractCanonical<media::TimeUnit>* CanonicalCurrentPosition()
{
return &mCurrentPosition;
}
AbstractCanonical<int64_t>* CanonicalPlaybackOffset()
{
return &mPlaybackOffset;
}
AbstractCanonical<bool>* CanonicalIsAudioDataAudible()