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

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

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