Bug 1126465 - Factor out calls to Request{Audio,Video}Data into a helper method. r=mattwoodrow

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

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

@ -140,7 +140,7 @@ MediaSourceReader::RequestAudioData()
}
// Fallback to using current reader
default:
RequestAudioDataComplete(0);
DoAudioRequest();
break;
}
return p;
@ -154,7 +154,11 @@ MediaSourceReader::RequestAudioDataComplete(int64_t aTime)
MOZ_RELEASE_ASSERT(mAudioPromise.IsEmpty()); // Already rejected in ::Seek().
return;
}
DoAudioRequest();
}
void MediaSourceReader::DoAudioRequest()
{
mAudioRequest.Begin(mAudioReader->RequestAudioData()
->RefableThen(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnAudioDecoded,
@ -289,10 +293,7 @@ MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThres
}
// Fallback to using current reader.
default:
mVideoRequest.Begin(mVideoReader->RequestVideoData(mDropVideoBeforeThreshold, mTimeThreshold)
->RefableThen(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnVideoDecoded,
&MediaSourceReader::OnVideoNotDecoded));
DoVideoRequest();
break;
}
@ -307,6 +308,12 @@ MediaSourceReader::RequestVideoDataComplete(int64_t aTime)
MOZ_ASSERT(mVideoPromise.IsEmpty()); // Already rejected in ::Seek().
return;
}
DoVideoRequest();
}
void
MediaSourceReader::DoVideoRequest()
{
mVideoRequest.Begin(mVideoReader->RequestVideoData(mDropVideoBeforeThreshold, mTimeThreshold)
->RefableThen(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnVideoDecoded,
@ -331,10 +338,7 @@ MediaSourceReader::OnVideoDecoded(VideoData* aSample)
if (aSample->mTime < mTimeThreshold) {
MSE_DEBUG("MediaSourceReader(%p)::OnVideoDecoded mTime=%lld < mTimeThreshold=%lld",
this, aSample->mTime, mTimeThreshold);
mVideoRequest.Begin(mVideoReader->RequestVideoData(mDropVideoBeforeThreshold, mTimeThreshold)
->RefableThen(GetTaskQueue(), __func__, this,
&MediaSourceReader::OnVideoDecoded,
&MediaSourceReader::OnVideoNotDecoded));
DoVideoRequest();
return;
}
mDropVideoBeforeThreshold = false;

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

@ -161,6 +161,10 @@ private:
};
SwitchReaderResult SwitchAudioReader(int64_t aTarget, int64_t aError = 0);
SwitchReaderResult SwitchVideoReader(int64_t aTarget, int64_t aError = 0);
void DoAudioRequest();
void DoVideoRequest();
void RequestAudioDataComplete(int64_t aTime);
void RequestAudioDataFailed(nsresult aResult);
void RequestVideoDataComplete(int64_t aTime);