Bug 1243608: P6. Only seek audio to video seek time when performing a fast seek. r=cpearce

This allows for much faster seek time.
This commit is contained in:
Jean-Yves Avenard 2016-01-28 23:25:15 +11:00
parent b89bc88b63
commit f54117c214
2 changed files with 14 additions and 10 deletions

View File

@ -1425,8 +1425,8 @@ MediaFormatReader::Seek(SeekTarget aTarget, int64_t aUnused)
return SeekPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
}
mOriginalSeekTime = Some(aTarget.GetTime());
mPendingSeekTime = mOriginalSeekTime;
mOriginalSeekTarget = Some(aTarget);
mPendingSeekTime = Some(aTarget.GetTime());
RefPtr<SeekPromise> p = mSeekPromise.Ensure(__func__);
@ -1470,8 +1470,8 @@ MediaFormatReader::OnSeekFailed(TrackType aTrack, DemuxerFailureReason aResult)
if (aResult == DemuxerFailureReason::WAITING_FOR_DATA) {
if (HasVideo() && aTrack == TrackType::kAudioTrack &&
mOriginalSeekTime.isSome() &&
mPendingSeekTime.ref() != mOriginalSeekTime.ref()) {
mOriginalSeekTarget.isSome() &&
mPendingSeekTime.ref() != mOriginalSeekTarget.ref().GetTime()) {
// We have failed to seek audio where video seeked to earlier.
// Attempt to seek instead to the closest point that we know we have in
// order to limit A/V sync discrepency.
@ -1487,11 +1487,11 @@ MediaFormatReader::OnSeekFailed(TrackType aTrack, DemuxerFailureReason aResult)
}
}
if (nextSeekTime.isNothing() ||
nextSeekTime.ref() > mOriginalSeekTime.ref()) {
nextSeekTime = mOriginalSeekTime;
nextSeekTime.ref() > mOriginalSeekTarget.ref().GetTime()) {
nextSeekTime = Some(mOriginalSeekTarget.ref().GetTime());
LOG("Unable to seek audio to video seek time. A/V sync may be broken");
} else {
mOriginalSeekTime.reset();
mOriginalSeekTarget.reset();
}
mPendingSeekTime = nextSeekTime;
DoAudioSeek();
@ -1525,8 +1525,12 @@ MediaFormatReader::OnVideoSeekCompleted(media::TimeUnit aTime)
mVideo.mSeekRequest.Complete();
if (HasAudio()) {
MOZ_ASSERT(mPendingSeekTime.isSome());
mPendingSeekTime = Some(aTime);
MOZ_ASSERT(mPendingSeekTime.isSome() && mOriginalSeekTarget.isSome());
if (mOriginalSeekTarget.ref().IsFast()) {
// We are performing a fast seek. We need to seek audio to where the
// video seeked to, to ensure proper A/V sync once playback resume.
mPendingSeekTime = Some(aTime);
}
DoAudioSeek();
} else {
mPendingSeekTime.reset();

View File

@ -466,7 +466,7 @@ private:
OnSeekFailed(TrackType::kAudioTrack, aFailure);
}
// Temporary seek information while we wait for the data
Maybe<media::TimeUnit> mOriginalSeekTime;
Maybe<SeekTarget> mOriginalSeekTarget;
Maybe<media::TimeUnit> mPendingSeekTime;
MozPromiseHolder<SeekPromise> mSeekPromise;