Bug 1242841 - Make MDSM::mDecodedAudioEndTime zero-based. r=kikuo.

This commit is contained in:
JW Wang 2016-01-26 11:31:56 +08:00
Родитель df24af8302
Коммит f2605266b2
1 изменённых файлов: 9 добавлений и 9 удалений

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

@ -213,7 +213,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mObservedDuration(TimeUnit(), "MediaDecoderStateMachine::mObservedDuration"),
mFragmentEndTime(-1),
mReader(aReader),
mDecodedAudioEndTime(-1),
mDecodedAudioEndTime(0),
mDecodedVideoEndTime(-1),
mPlaybackRate(1.0),
mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS),
@ -424,9 +424,10 @@ MediaDecoderStateMachine::GetDecodedAudioDuration()
{
MOZ_ASSERT(OnTaskQueue());
if (mMediaSink->IsStarted()) {
// |mDecodedAudioEndTime == -1| means no decoded audio at all so the
// returned duration is 0.
return mDecodedAudioEndTime != -1 ? mDecodedAudioEndTime - GetClock() : 0;
// 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>(mDecodedAudioEndTime - GetClock(), 0);
}
// MediaSink not started. All audio samples are in the queue.
return AudioQueue().Duration();
@ -606,7 +607,9 @@ MediaDecoderStateMachine::OnAudioDecoded(MediaData* aAudioSample)
MOZ_ASSERT(audio);
mAudioDataRequest.Complete();
aAudioSample->AdjustForStartTime(StartTime());
mDecodedAudioEndTime = audio->GetEndTime();
// audio->GetEndTime() is not always mono-increasing in chained ogg.
mDecodedAudioEndTime = std::max(audio->GetEndTime(), mDecodedAudioEndTime);
SAMPLE_LOG("OnAudioDecoded [%lld,%lld] disc=%d",
(audio ? audio->mTime : -1),
@ -1878,9 +1881,6 @@ bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
}
int64_t endOfDecodedAudioData = INT64_MAX;
if (HasAudio() && !AudioQueue().AtEndOfStream()) {
// mDecodedAudioEndTime could be -1 when no audio samples are decoded.
// But that is fine since we consider ourself as low in decoded data when
// we don't have any decoded audio samples at all.
endOfDecodedAudioData = mDecodedAudioEndTime;
}
int64_t endOfDecodedData = std::min(endOfDecodedVideoData, endOfDecodedAudioData);
@ -2390,7 +2390,7 @@ MediaDecoderStateMachine::Reset()
StopMediaSink();
mDecodedVideoEndTime = -1;
mDecodedAudioEndTime = -1;
mDecodedAudioEndTime = 0;
mAudioCompleted = false;
mVideoCompleted = false;
AudioQueue().Reset();