Bug 1330254. Part 1 - move MDSM::Ensure{Audio,Video}DecodeTaskQueued into DecodingState. r=kikuo

MozReview-Commit-ID: 9xPNQ9E7R3E

--HG--
extra : rebase_source : b4b329cafb223b1af3e116d6605ef1e4dcefc31d
extra : intermediate-source : 619564872603b357b395b2ff8e8a6f7f0fb80d62
extra : source : 77eb9d0c761c0441f2f73d5eb4be69382f7d02ec
This commit is contained in:
JW Wang 2017-01-09 21:11:01 +08:00
Родитель bcd83bc12f
Коммит a1b72a6467
2 изменённых файлов: 36 добавлений и 63 удалений

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

@ -675,12 +675,12 @@ public:
void HandleAudioCanceled() override
{
mMaster->EnsureAudioDecodeTaskQueued();
EnsureAudioDecodeTaskQueued();
}
void HandleVideoCanceled() override
{
mMaster->EnsureVideoDecodeTaskQueued();
EnsureVideoDecodeTaskQueued();
}
void HandleEndOfAudio() override;
@ -700,12 +700,12 @@ public:
void HandleAudioWaited(MediaData::Type aType) override
{
mMaster->EnsureAudioDecodeTaskQueued();
EnsureAudioDecodeTaskQueued();
}
void HandleVideoWaited(MediaData::Type aType) override
{
mMaster->EnsureVideoDecodeTaskQueued();
EnsureVideoDecodeTaskQueued();
}
void HandleAudioCaptured() override
@ -747,6 +747,8 @@ public:
private:
void DispatchDecodeTasksIfNeeded();
void EnsureAudioDecodeTaskQueued();
void EnsureVideoDecodeTaskQueued();
void MaybeStartBuffering();
void CheckSlowDecoding(TimeStamp aDecodeStart)
@ -2087,13 +2089,13 @@ DecodingState::Enter()
mOnAudioPopped = AudioQueue().PopEvent().Connect(
OwnerThread(), [this] () {
if (mMaster->IsAudioDecoding() && !mMaster->HaveEnoughDecodedAudio()) {
mMaster->EnsureAudioDecodeTaskQueued();
EnsureAudioDecodeTaskQueued();
}
});
mOnVideoPopped = VideoQueue().PopEvent().Connect(
OwnerThread(), [this] () {
if (mMaster->IsVideoDecoding() && !mMaster->HaveEnoughDecodedVideo()) {
mMaster->EnsureVideoDecodeTaskQueued();
EnsureVideoDecodeTaskQueued();
}
});
@ -2145,16 +2147,42 @@ DecodingState::DispatchDecodeTasksIfNeeded()
if (mMaster->IsAudioDecoding() &&
!mMaster->mMinimizePreroll &&
!mMaster->HaveEnoughDecodedAudio()) {
mMaster->EnsureAudioDecodeTaskQueued();
EnsureAudioDecodeTaskQueued();
}
if (mMaster->IsVideoDecoding() &&
!mMaster->mMinimizePreroll &&
!mMaster->HaveEnoughDecodedVideo()) {
mMaster->EnsureVideoDecodeTaskQueued();
EnsureVideoDecodeTaskQueued();
}
}
void
MediaDecoderStateMachine::
DecodingState::EnsureAudioDecodeTaskQueued()
{
if (!mMaster->IsAudioDecoding() ||
mMaster->IsRequestingAudioData() ||
mMaster->IsWaitingAudioData()) {
return;
}
mMaster->RequestAudioData();
}
void
MediaDecoderStateMachine::
DecodingState::EnsureVideoDecodeTaskQueued()
{
if (!mMaster->IsVideoDecoding() ||
mMaster->IsRequestingVideoData() ||
mMaster->IsWaitingVideoData()) {
return;
}
mMaster->RequestVideoData(mMaster->NeedToSkipToNextKeyframe(),
media::TimeUnit::FromMicroseconds(mMaster->GetMediaTime()));
}
void
MediaDecoderStateMachine::
DecodingState::MaybeStartBuffering()
@ -2991,30 +3019,6 @@ void MediaDecoderStateMachine::StopMediaSink()
}
}
void
MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(mState != DECODER_STATE_SEEKING);
MOZ_ASSERT(mState != DECODER_STATE_DECODING_FIRSTFRAME);
SAMPLE_LOG("EnsureAudioDecodeTaskQueued isDecoding=%d status=%s",
IsAudioDecoding(), AudioRequestStatus());
if (mState != DECODER_STATE_DECODING &&
mState != DECODER_STATE_BUFFERING) {
return;
}
if (!IsAudioDecoding() ||
IsRequestingAudioData() ||
IsWaitingAudioData()) {
return;
}
RequestAudioData();
}
void
MediaDecoderStateMachine::RequestAudioData()
{
@ -3056,31 +3060,6 @@ MediaDecoderStateMachine::RequestAudioData()
);
}
void
MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(mState != DECODER_STATE_SEEKING);
MOZ_ASSERT(mState != DECODER_STATE_DECODING_FIRSTFRAME);
SAMPLE_LOG("EnsureVideoDecodeTaskQueued isDecoding=%d status=%s",
IsVideoDecoding(), VideoRequestStatus());
if (mState != DECODER_STATE_DECODING &&
mState != DECODER_STATE_BUFFERING) {
return;
}
if (!IsVideoDecoding() ||
IsRequestingVideoData() ||
IsWaitingVideoData()) {
return;
}
RequestVideoData(NeedToSkipToNextKeyframe(),
media::TimeUnit::FromMicroseconds(GetMediaTime()));
}
void
MediaDecoderStateMachine::RequestVideoData(bool aSkipToNextKeyframe,
const media::TimeUnit& aCurrentTime)

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

@ -408,12 +408,6 @@ protected:
void EnqueueFirstFrameLoadedEvent();
// Dispatch a task to decode audio if there is not.
void EnsureAudioDecodeTaskQueued();
// Dispatch a task to decode video if there is not.
void EnsureVideoDecodeTaskQueued();
// Start a task to decode audio.
void RequestAudioData();