Bug 1134064: Part4. Fix racing condition should data get evicted. r=mattwoodrow

Should required data get evicted between the time we checked for availability
and the time we started seeking, it would have caused the seek to fail. Instead
cancel current seek and go back waiting for more data.
This commit is contained in:
Jean-Yves Avenard 2015-02-24 16:38:41 +11:00
parent 7c9260ddd3
commit 2c4cc92b83

View File

@ -810,8 +810,12 @@ MediaSourceReader::OnVideoSeekFailed(nsresult aResult)
void
MediaSourceReader::DoAudioSeek()
{
SwitchAudioSource(&mPendingSeekTime);
MOZ_ASSERT(GetAudioReader());
if (SwitchAudioSource(&mPendingSeekTime) == SOURCE_NONE) {
// Data we need got evicted since the last time we checked for data
// availability. Abort current seek attempt.
mWaitingForSeekData = true;
return;
}
mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(mPendingSeekTime), 0)
->RefableThen(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnAudioSeekCompleted,
@ -876,8 +880,12 @@ MediaSourceReader::AttemptSeek()
void
MediaSourceReader::DoVideoSeek()
{
SwitchVideoSource(&mPendingSeekTime);
MOZ_ASSERT(GetVideoReader());
if (SwitchVideoSource(&mPendingSeekTime) == SOURCE_NONE) {
// Data we need got evicted since the last time we checked for data
// availability. Abort current seek attempt.
mWaitingForSeekData = true;
return;
}
mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(mPendingSeekTime), 0)
->RefableThen(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnVideoSeekCompleted,