Bug 1112438 - Make newCurrentFrameTime more accurate while seeking by checking audio & video timestamp boundary in addition. r=cpearce

This commit is contained in:
Kilik Kuo 2015-02-17 11:21:40 +08:00
Родитель 6e9087fc50
Коммит cbe28e8d8f
1 изменённых файлов: 10 добавлений и 1 удалений

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

@ -2592,7 +2592,16 @@ MediaDecoderStateMachine::SeekCompleted()
newCurrentTime = mAudioStartTime = seekTime;
} else if (HasAudio()) {
AudioData* audio = AudioQueue().PeekFront();
newCurrentTime = mAudioStartTime = audio ? audio->mTime : seekTime;
// Though we adjust the newCurrentTime in audio-based, and supplemented
// by video. For better UX, should NOT bind the slide position to
// the first audio data timestamp directly.
// While seeking to a position where there's only either audio or video, or
// seeking to a position lies before audio or video, we need to check if
// seekTime is bounded in suitable duration. See Bug 1112438.
int64_t videoStart = video ? video->mTime : seekTime;
int64_t audioStart = audio ? audio->mTime : seekTime;
newCurrentTime = mAudioStartTime =
std::min(std::min(audioStart, videoStart), seekTime);
} else {
newCurrentTime = video ? video->mTime : seekTime;
}