Backed out changeset ca140e7557d6 (bug 883731)

This commit is contained in:
Carsten "Tomcat" Book 2014-09-29 10:57:28 +02:00
parent e83fe62a11
commit ef37d240f6
5 changed files with 22 additions and 20 deletions

View File

@ -2952,6 +2952,18 @@ void HTMLMediaElement::FirstFrameLoaded()
mPreloadAction == HTMLMediaElement::PRELOAD_METADATA) {
mSuspendedAfterFirstFrame = true;
mDecoder->Suspend();
} else if (mDownloadSuspendedByCache &&
mDecoder && !mDecoder->IsEnded()) {
// We've already loaded the first frame, and the decoder has signalled
// that the download has been suspended by the media cache. So move
// readyState into HAVE_ENOUGH_DATA, in case there's script waiting
// for a "canplaythrough" event; without this forced transition, we will
// never fire the "canplaythrough" event if the media cache is so small
// that the download was suspended before the first frame was loaded.
// Don't force this transition if the decoder is in ended state; the
// readyState should remain at HAVE_CURRENT_DATA in this case.
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA);
return;
}
}
@ -3046,6 +3058,7 @@ void HTMLMediaElement::SeekStarted()
if(mPlayingThroughTheAudioChannel) {
mPlayingThroughTheAudioChannelBeforeSeek = true;
}
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
FireTimeUpdate(false);
}
@ -3121,11 +3134,6 @@ void HTMLMediaElement::UpdateReadyStateForData(MediaDecoderOwner::NextFrameStatu
return;
}
if (aNextFrame == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING) {
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
return;
}
if (mDownloadSuspendedByCache && mDecoder && !mDecoder->IsEnded()) {
// The decoder has signaled that the download has been suspended by the
// media cache. So move readyState into HAVE_ENOUGH_DATA, in case there's
@ -3200,7 +3208,7 @@ void HTMLMediaElement::ChangeReadyState(nsMediaReadyState aState)
// Handle raising of "waiting" event during seek (see 4.8.10.9)
if (mPlayingBeforeSeek &&
mReadyState < nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA) {
oldState < nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA) {
DispatchAsyncEvent(NS_LITERAL_STRING("waiting"));
}

View File

@ -942,8 +942,10 @@ void MediaDecoder::UpdatePlaybackRate()
void MediaDecoder::NotifySuspendedStatusChanged()
{
MOZ_ASSERT(NS_IsMainThread());
if (mResource && mOwner) {
bool suspended = mResource->IsSuspendedByCache();
if (!mResource)
return;
bool suspended = mResource->IsSuspendedByCache();
if (mOwner) {
mOwner->NotifySuspendedByCache(suspended);
UpdateReadyStateForData();
}
@ -956,6 +958,7 @@ void MediaDecoder::NotifyBytesDownloaded()
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
UpdatePlaybackRate();
}
UpdateReadyStateForData();
Progress(false);
}
@ -979,10 +982,9 @@ void MediaDecoder::NotifyDownloadEnded(nsresult aStatus)
}
if (NS_SUCCEEDED(aStatus)) {
UpdateReadyStateForData();
// A final progress event will be fired by the MediaResource calling
// DownloadSuspended on the element.
// Also NotifySuspendedStatusChanged() will be called to update readyState
// if download ended with success.
} else if (aStatus != NS_BASE_STREAM_CLOSED) {
NetworkError();
}

View File

@ -108,8 +108,6 @@ public:
// The next frame of audio/video is unavailable because the decoder
// is paused while it buffers up data
NEXT_FRAME_UNAVAILABLE_BUFFERING,
// The next frame of audio/video is unavailable for the decoder is seeking.
NEXT_FRAME_UNAVAILABLE_SEEKING,
// The next frame of audio/video is unavailable for some other reasons
NEXT_FRAME_UNAVAILABLE,
// The next frame is unavailable due to waiting for more Media Source

View File

@ -1212,10 +1212,8 @@ void MediaDecoderStateMachine::ClearPositionChangeFlag()
MediaDecoderOwner::NextFrameStatus MediaDecoderStateMachine::GetNextFrameStatus()
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (IsBuffering()) {
if (IsBuffering() || IsSeeking()) {
return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING;
} else if (IsSeeking()) {
return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING;
} else if (HaveNextFrameData()) {
return MediaDecoderOwner::NEXT_FRAME_AVAILABLE;
}
@ -2888,10 +2886,6 @@ void MediaDecoderStateMachine::UpdateReadyState() {
AssertCurrentThreadInMonitor();
MediaDecoderOwner::NextFrameStatus nextFrameStatus = GetNextFrameStatus();
// FIXME: This optimization could result in inconsistent next frame status
// between the decoder and state machine when GetNextFrameStatus() is called
// by the decoder without updating mLastFrameStatus.
// Note not to regress bug 882027 when fixing this bug.
if (nextFrameStatus == mLastFrameStatus) {
return;
}

View File

@ -669,7 +669,7 @@ MediaDecoderOwner::NextFrameStatus AudioOffloadPlayer::GetNextFrameStatus()
{
MOZ_ASSERT(NS_IsMainThread());
if (mPlayState == MediaDecoder::PLAY_STATE_SEEKING) {
return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING;
return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING;
} else if (mPlayState == MediaDecoder::PLAY_STATE_ENDED) {
return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
} else {