Bug 1358969 - let MediaDecoder::CurrentPosition() return a TimeUnit. r=kikuo

We want to replace the use of int64_t for microseconds by TimeUnit
whenever possible since int64_t is ambiguous which could be microseconds
or milliseconds.

MozReview-Commit-ID: K3Bz3uEXLDK

--HG--
extra : rebase_source : ade3cbd61c764b73a22c360572a525127dbadbc5
extra : intermediate-source : 013227a4aa645fc34a82c44130db6c847d74960b
extra : source : 1ab7ce426b557e4ce9979e023f9e84b4690eeaaa
This commit is contained in:
JW Wang 2017-04-17 17:04:39 +08:00
Родитель ce7bb69227
Коммит f6a893a644
3 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -1183,8 +1183,7 @@ MediaDecoder::UpdateLogicalPositionInternal()
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
double currentPosition =
static_cast<double>(CurrentPosition()) / static_cast<double>(USECS_PER_S);
double currentPosition = CurrentPosition().ToSeconds();
if (mPlayState == PLAY_STATE_ENDED) {
currentPosition = std::max(currentPosition, mDuration);
}
@ -1234,7 +1233,7 @@ MediaDecoder::DurationChanged()
GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
}
if (CurrentPosition() > TimeUnit::FromSeconds(mDuration).ToMicroseconds()) {
if (CurrentPosition() > TimeUnit::FromSeconds(mDuration)) {
Seek(mDuration, SeekTarget::Accurate);
}
}
@ -1772,7 +1771,7 @@ MediaDecoder::NextFrameBufferedStatus()
MOZ_ASSERT(NS_IsMainThread());
// Next frame hasn't been decoded yet.
// Use the buffered range to consider if we have the next frame available.
TimeUnit currentPosition = TimeUnit::FromMicroseconds(CurrentPosition());
auto currentPosition = CurrentPosition();
media::TimeInterval interval(
currentPosition,
currentPosition + DEFAULT_NEXT_FRAME_AVAILABLE_BUFFERED);

Просмотреть файл

@ -568,9 +568,9 @@ protected:
// 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()
virtual media::TimeUnit CurrentPosition()
{
return mCurrentPosition.Ref().ToMicroseconds();
return mCurrentPosition.Ref();
}
// Official duration of the media resource as observed by script.

Просмотреть файл

@ -281,7 +281,7 @@ MediaSourceDecoder::NextFrameBufferedStatus()
// Next frame hasn't been decoded yet.
// Use the buffered range to consider if we have the next frame available.
TimeUnit currentPosition = TimeUnit::FromMicroseconds(CurrentPosition());
auto currentPosition = CurrentPosition();
TimeIntervals buffered = GetBuffered();
buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
TimeInterval interval(
@ -306,7 +306,7 @@ MediaSourceDecoder::CanPlayThrough()
return false;
}
TimeUnit duration = TimeUnit::FromSeconds(mMediaSource->Duration());
TimeUnit currentPosition = TimeUnit::FromMicroseconds(CurrentPosition());
auto currentPosition = CurrentPosition();
if (duration.IsInfinite()) {
// We can't make an informed decision and just assume that it's a live
// stream