Bug 1126465 - Factor out the seeking phases into helper methods. r=mattwoodrow

This commit is contained in:
Bobby Holley 2015-01-29 22:11:11 -08:00
Родитель ab4d30db7c
Коммит f98dfa3c8f
2 изменённых файлов: 29 добавлений и 13 удалений

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

@ -750,17 +750,23 @@ MediaSourceReader::OnVideoSeekCompleted(int64_t aTime)
if (mAudioTrack) {
mPendingSeekTime = aTime;
DoAudioSeek();
} else {
mPendingSeekTime = -1;
mSeekPromise.Resolve(aTime, __func__);
}
}
void
MediaSourceReader::DoAudioSeek()
{
mAudioIsSeeking = true;
SwitchAudioReader(mPendingSeekTime);
mAudioReader->Seek(mPendingSeekTime, 0)
->Then(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnAudioSeekCompleted,
&MediaSourceReader::OnSeekFailed);
MSE_DEBUG("MediaSourceReader(%p)::Seek audio reader=%p", this, mAudioReader.get());
return;
}
mPendingSeekTime = -1;
mSeekPromise.Resolve(aTime, __func__);
MSE_DEBUG("MediaSourceReader(%p)::DoAudioSeek reader=%p", this, mAudioReader.get());
}
void
@ -817,18 +823,26 @@ MediaSourceReader::AttemptSeek()
mLastVideoTime = mPendingSeekTime;
if (mVideoTrack) {
mVideoIsSeeking = true;
SwitchVideoReader(mPendingSeekTime);
mVideoReader->Seek(mPendingSeekTime, 0)
->Then(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnVideoSeekCompleted,
&MediaSourceReader::OnSeekFailed);
MSE_DEBUG("MediaSourceReader(%p)::Seek video reader=%p", this, mVideoReader.get());
DoVideoSeek();
} else if (mAudioTrack) {
DoAudioSeek();
} else {
OnVideoSeekCompleted(mPendingSeekTime);
MOZ_CRASH();
}
}
void
MediaSourceReader::DoVideoSeek()
{
mVideoIsSeeking = true;
SwitchVideoReader(mPendingSeekTime);
mVideoReader->Seek(mPendingSeekTime, 0)
->Then(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnVideoSeekCompleted,
&MediaSourceReader::OnSeekFailed);
MSE_DEBUG("MediaSourceReader(%p)::DoVideoSeek reader=%p", this, mVideoReader.get());
}
nsresult
MediaSourceReader::GetBuffered(dom::TimeRanges* aBuffered)
{

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

@ -61,6 +61,8 @@ public:
void OnVideoDecoded(VideoData* aSample);
void OnVideoNotDecoded(NotDecodedReason aReason);
void DoVideoSeek();
void DoAudioSeek();
void OnVideoSeekCompleted(int64_t aTime);
void OnAudioSeekCompleted(int64_t aTime);
void OnSeekFailed(nsresult aResult);