From 849a835855a287fe397c75bf654b5f8b7f29e8ca Mon Sep 17 00:00:00 2001 From: JW Wang Date: Fri, 6 Jan 2017 17:43:05 +0800 Subject: [PATCH] Bug 1329110. Part 1 - add HandleWaitingForAudio(). r=kaku MozReview-Commit-ID: B2ElMMYKt7m --HG-- extra : rebase_source : da07871951b787e8c101a490ea78107e11ad80e8 extra : intermediate-source : da16ca5f7b522b191b183a4923722b3e4141117f extra : source : 558d053ca2f80d9ed52bb72d2f822ec2ae36dfb6 --- dom/media/MediaDecoderStateMachine.cpp | 42 +++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index f9ac3b0f71cb..465140bfdcb9 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -203,6 +203,12 @@ public: virtual void HandleWaitingForData() {} virtual void HandleAudioCaptured() {} + virtual void HandleWaitingForAudio() + { + mMaster->WaitForData(MediaData::AUDIO_DATA); + HandleWaitingForData(); + } + virtual RefPtr HandleSeek(SeekTarget aTarget); virtual RefPtr HandleShutdown(); @@ -498,6 +504,11 @@ public: MaybeFinishDecodeFirstFrame(); } + void HandleWaitingForAudio() override + { + mMaster->WaitForData(MediaData::AUDIO_DATA); + } + void HandleAudioNotDecoded(const MediaResult& aError) override; void HandleVideoNotDecoded(const MediaResult& aError) override; @@ -934,6 +945,14 @@ public: MaybeFinishSeek(); } + void HandleWaitingForAudio() override + { + if (!mSeekJob.mTarget->IsVideoOnly()) { + MOZ_ASSERT(!mDoneAudioSeeking); + mMaster->WaitForData(MediaData::AUDIO_DATA); + } + } + void HandleAudioNotDecoded(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 HandleVideoNotDecoded(const MediaResult& aError) override; @@ -1695,8 +1722,7 @@ StateObject::HandleAudioNotDecoded(const MediaResult& aError) { switch (aError.Code()) { case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: - mMaster->WaitForData(MediaData::AUDIO_DATA); - HandleWaitingForData(); + MOZ_ASSERT(false); break; case NS_ERROR_DOM_MEDIA_CANCELED: mMaster->EnsureAudioDecodeTaskQueued(); @@ -1933,7 +1959,7 @@ DecodingFirstFrameState::HandleAudioNotDecoded(const MediaResult& aError) { switch (aError.Code()) { case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: - mMaster->WaitForData(MediaData::AUDIO_DATA); + MOZ_ASSERT(false); break; case NS_ERROR_DOM_MEDIA_CANCELED: mMaster->RequestAudioData(); @@ -2156,7 +2182,7 @@ AccurateSeekingState::HandleAudioNotDecoded(const MediaResult& aError) MOZ_ASSERT(!mDoneAudioSeeking); switch (aError.Code()) { case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: - mMaster->WaitForData(MediaData::AUDIO_DATA); + MOZ_ASSERT(false); break; case NS_ERROR_DOM_MEDIA_CANCELED: RequestAudioData(); @@ -3011,7 +3037,13 @@ MediaDecoderStateMachine::RequestAudioData() [this] (const MediaResult& aError) { SAMPLE_LOG("OnAudioNotDecoded aError=%u", aError.Code()); mAudioDataRequest.Complete(); - mStateObj->HandleAudioNotDecoded(aError); + switch (aError.Code()) { + case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA: + mStateObj->HandleWaitingForAudio(); + break; + default: + mStateObj->HandleAudioNotDecoded(aError); + } }) ); }