Bug 1120017 - Make the DispatchDecodeTasksIfNeeded path handle DECODER_STATE_DECODING_FIRSTFRAME. r=cpearce

Once we make MP4Reader reject with WAITING_FOR_DATA, we end up with the following scenario:

DecodeFirstFrame requests audio data, and then it gets rejected with WAITING_FOR_DATA.
So OnAudioNotDecided does WaitForData, which eventually causes us to be called back in
MediaDecoderStateMachine::WaitForDataResolved. That does DispatchDecodeTasksIfNeeded, which
currently bails out of our state is DECODER_STATE_DECODING_FIRSTFRAME.

The other way to do this would be to add a separate specialized path through all this
asynchronicity for DECODER_STATE_DECODING_FIRSTFRAME. But it's not clear to me what that
buys us.
This commit is contained in:
Bobby Holley 2015-01-09 17:20:58 -08:00
parent fb7b849eb3
commit 8d967098a2

View File

@ -576,6 +576,9 @@ bool
MediaDecoderStateMachine::NeedToSkipToNextKeyframe() MediaDecoderStateMachine::NeedToSkipToNextKeyframe()
{ {
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
if (mState == DECODER_STATE_DECODING_FIRSTFRAME) {
return false;
}
MOZ_ASSERT(mState == DECODER_STATE_DECODING || MOZ_ASSERT(mState == DECODER_STATE_DECODING ||
mState == DECODER_STATE_BUFFERING || mState == DECODER_STATE_BUFFERING ||
mState == DECODER_STATE_SEEKING); mState == DECODER_STATE_SEEKING);
@ -623,6 +626,7 @@ MediaDecoderStateMachine::DecodeVideo()
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread."); NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
if (mState != DECODER_STATE_DECODING && if (mState != DECODER_STATE_DECODING &&
mState != DECODER_STATE_DECODING_FIRSTFRAME &&
mState != DECODER_STATE_BUFFERING && mState != DECODER_STATE_BUFFERING &&
mState != DECODER_STATE_SEEKING) { mState != DECODER_STATE_SEEKING) {
mVideoRequestStatus = RequestStatus::Idle; mVideoRequestStatus = RequestStatus::Idle;
@ -672,6 +676,7 @@ MediaDecoderStateMachine::DecodeAudio()
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread."); NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
if (mState != DECODER_STATE_DECODING && if (mState != DECODER_STATE_DECODING &&
mState != DECODER_STATE_DECODING_FIRSTFRAME &&
mState != DECODER_STATE_BUFFERING && mState != DECODER_STATE_BUFFERING &&
mState != DECODER_STATE_SEEKING) { mState != DECODER_STATE_SEEKING) {
mAudioRequestStatus = RequestStatus::Idle; mAudioRequestStatus = RequestStatus::Idle;
@ -1777,6 +1782,7 @@ MediaDecoderStateMachine::DispatchDecodeTasksIfNeeded()
AssertCurrentThreadInMonitor(); AssertCurrentThreadInMonitor();
if (mState != DECODER_STATE_DECODING && if (mState != DECODER_STATE_DECODING &&
mState != DECODER_STATE_DECODING_FIRSTFRAME &&
mState != DECODER_STATE_BUFFERING && mState != DECODER_STATE_BUFFERING &&
mState != DECODER_STATE_SEEKING) { mState != DECODER_STATE_SEEKING) {
return; return;
@ -1892,7 +1898,7 @@ MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
return NS_OK; return NS_OK;
} }
MOZ_ASSERT(mState > DECODER_STATE_DECODING_FIRSTFRAME); MOZ_ASSERT(mState >= DECODER_STATE_DECODING_FIRSTFRAME);
if (IsAudioDecoding() && mAudioRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) { if (IsAudioDecoding() && mAudioRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) {
RefPtr<nsIRunnable> task( RefPtr<nsIRunnable> task(
@ -1937,7 +1943,7 @@ MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
return NS_OK; return NS_OK;
} }
MOZ_ASSERT(mState > DECODER_STATE_DECODING_FIRSTFRAME); MOZ_ASSERT(mState >= DECODER_STATE_DECODING_FIRSTFRAME);
if (IsVideoDecoding() && mVideoRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) { if (IsVideoDecoding() && mVideoRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) {
RefPtr<nsIRunnable> task( RefPtr<nsIRunnable> task(