Bug 1329110. Part 1 - add HandleWaitingForAudio(). r=kaku

MozReview-Commit-ID: B2ElMMYKt7m

--HG--
extra : rebase_source : da07871951b787e8c101a490ea78107e11ad80e8
extra : intermediate-source : da16ca5f7b522b191b183a4923722b3e4141117f
extra : source : 558d053ca2f80d9ed52bb72d2f822ec2ae36dfb6
This commit is contained in:
JW Wang 2017-01-06 17:43:05 +08:00
Родитель 857b7ed220
Коммит 849a835855
1 изменённых файлов: 37 добавлений и 5 удалений

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

@ -203,6 +203,12 @@ public:
virtual void HandleWaitingForData() {} virtual void HandleWaitingForData() {}
virtual void HandleAudioCaptured() {} virtual void HandleAudioCaptured() {}
virtual void HandleWaitingForAudio()
{
mMaster->WaitForData(MediaData::AUDIO_DATA);
HandleWaitingForData();
}
virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget); virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget);
virtual RefPtr<ShutdownPromise> HandleShutdown(); virtual RefPtr<ShutdownPromise> HandleShutdown();
@ -498,6 +504,11 @@ public:
MaybeFinishDecodeFirstFrame(); MaybeFinishDecodeFirstFrame();
} }
void HandleWaitingForAudio() override
{
mMaster->WaitForData(MediaData::AUDIO_DATA);
}
void HandleAudioNotDecoded(const MediaResult& aError) override; void HandleAudioNotDecoded(const MediaResult& aError) override;
void HandleVideoNotDecoded(const MediaResult& aError) override; void HandleVideoNotDecoded(const MediaResult& aError) override;
@ -934,6 +945,14 @@ public:
MaybeFinishSeek(); MaybeFinishSeek();
} }
void HandleWaitingForAudio() override
{
if (!mSeekJob.mTarget->IsVideoOnly()) {
MOZ_ASSERT(!mDoneAudioSeeking);
mMaster->WaitForData(MediaData::AUDIO_DATA);
}
}
void HandleAudioNotDecoded(const MediaResult& aError) override; void HandleAudioNotDecoded(const MediaResult& aError) override;
void HandleVideoNotDecoded(const MediaResult& aError) override; void HandleVideoNotDecoded(const MediaResult& aError) override;
@ -1348,6 +1367,14 @@ private:
} }
} }
void HandleWaitingForAudio() override
{
MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished");
MOZ_ASSERT(NeedMoreVideo());
// We don't care about audio decode errors in this state which will be
// handled by other states after seeking.
}
void HandleAudioNotDecoded(const MediaResult& aError) override; void HandleAudioNotDecoded(const MediaResult& aError) override;
void HandleVideoNotDecoded(const MediaResult& aError) override; void HandleVideoNotDecoded(const MediaResult& aError) override;
@ -1695,8 +1722,7 @@ StateObject::HandleAudioNotDecoded(const MediaResult& aError)
{ {
switch (aError.Code()) { switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mMaster->WaitForData(MediaData::AUDIO_DATA); MOZ_ASSERT(false);
HandleWaitingForData();
break; break;
case NS_ERROR_DOM_MEDIA_CANCELED: case NS_ERROR_DOM_MEDIA_CANCELED:
mMaster->EnsureAudioDecodeTaskQueued(); mMaster->EnsureAudioDecodeTaskQueued();
@ -1933,7 +1959,7 @@ DecodingFirstFrameState::HandleAudioNotDecoded(const MediaResult& aError)
{ {
switch (aError.Code()) { switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mMaster->WaitForData(MediaData::AUDIO_DATA); MOZ_ASSERT(false);
break; break;
case NS_ERROR_DOM_MEDIA_CANCELED: case NS_ERROR_DOM_MEDIA_CANCELED:
mMaster->RequestAudioData(); mMaster->RequestAudioData();
@ -2156,7 +2182,7 @@ AccurateSeekingState::HandleAudioNotDecoded(const MediaResult& aError)
MOZ_ASSERT(!mDoneAudioSeeking); MOZ_ASSERT(!mDoneAudioSeeking);
switch (aError.Code()) { switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mMaster->WaitForData(MediaData::AUDIO_DATA); MOZ_ASSERT(false);
break; break;
case NS_ERROR_DOM_MEDIA_CANCELED: case NS_ERROR_DOM_MEDIA_CANCELED:
RequestAudioData(); RequestAudioData();
@ -3011,7 +3037,13 @@ MediaDecoderStateMachine::RequestAudioData()
[this] (const MediaResult& aError) { [this] (const MediaResult& aError) {
SAMPLE_LOG("OnAudioNotDecoded aError=%u", aError.Code()); SAMPLE_LOG("OnAudioNotDecoded aError=%u", aError.Code());
mAudioDataRequest.Complete(); mAudioDataRequest.Complete();
mStateObj->HandleAudioNotDecoded(aError); switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mStateObj->HandleWaitingForAudio();
break;
default:
mStateObj->HandleAudioNotDecoded(aError);
}
}) })
); );
} }