Bug 1353607. P2 - let GetDecodedAudioDuration() return a TimeUnit. r=kikuo

MozReview-Commit-ID: 5pLyACshP3e

--HG--
extra : rebase_source : ffc0235f14c12d4d8f44871ae5769a171222aebd
extra : intermediate-source : 422eff08d660192625ccabd4f2f063418ddab460
extra : source : ba186badc48371a0db16a1ffce8f188030558129
This commit is contained in:
JW Wang 2017-03-28 16:54:39 +08:00
Родитель 613fc16b11
Коммит fde98e4988
2 изменённых файлов: 9 добавлений и 8 удалений

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

@ -854,7 +854,7 @@ private:
bool DonePrerollingAudio()
{
return !mMaster->IsAudioDecoding()
|| mMaster->GetDecodedAudioDuration()
|| mMaster->GetDecodedAudioDuration().ToMicroseconds()
>= AudioPrerollThreshold().ToMicroseconds() * mMaster->mPlaybackRate;
}
@ -2320,7 +2320,7 @@ DecodingState::NeedToSkipToNextKeyframe()
bool isLowOnDecodedAudio =
!Reader()->IsAsync()
&& mMaster->IsAudioDecoding()
&& (mMaster->GetDecodedAudioDuration()
&& (mMaster->GetDecodedAudioDuration().ToMicroseconds()
< mMaster->mLowAudioThreshold.ToMicroseconds() * mMaster->mPlaybackRate);
bool isLowOnDecodedVideo =
(mMaster->GetClock().ToMicroseconds() - mMaster->mDecodedVideoEndTime)
@ -2757,7 +2757,7 @@ MediaDecoderStateMachine::CreateMediaSink(bool aAudioCaptured)
return mediaSink.forget();
}
int64_t
TimeUnit
MediaDecoderStateMachine::GetDecodedAudioDuration()
{
MOZ_ASSERT(OnTaskQueue());
@ -2765,11 +2765,12 @@ MediaDecoderStateMachine::GetDecodedAudioDuration()
// mDecodedAudioEndTime might be smaller than GetClock() when there is
// overlap between 2 adjacent audio samples or when we are playing
// a chained ogg file.
return std::max<int64_t>(
auto t = std::max<int64_t>(
mDecodedAudioEndTime - GetClock().ToMicroseconds(), 0);
return TimeUnit::FromMicroseconds(t);
}
// MediaSink not started. All audio samples are in the queue.
return AudioQueue().Duration();
return TimeUnit::FromMicroseconds(AudioQueue().Duration());
}
bool
@ -2778,7 +2779,7 @@ MediaDecoderStateMachine::HaveEnoughDecodedAudio()
MOZ_ASSERT(OnTaskQueue());
auto ampleAudioUSecs = mAmpleAudioThreshold.ToMicroseconds() * mPlaybackRate;
return AudioQueue().GetSize() > 0
&& GetDecodedAudioDuration() >= ampleAudioUSecs;
&& GetDecodedAudioDuration().ToMicroseconds() >= ampleAudioUSecs;
}
bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
@ -3307,7 +3308,7 @@ MediaDecoderStateMachine::HasLowDecodedAudio()
{
MOZ_ASSERT(OnTaskQueue());
return IsAudioDecoding()
&& GetDecodedAudioDuration()
&& GetDecodedAudioDuration().ToMicroseconds()
< EXHAUSTED_DATA_MARGIN_USECS * mPlaybackRate;
}

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

@ -459,7 +459,7 @@ protected:
// 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
// must be held when calling this. Called on the decode thread.
int64_t GetDecodedAudioDuration();
media::TimeUnit GetDecodedAudioDuration();
void FinishDecodeFirstFrame();