Bug 1378085 P8 - always dispatch VideoOnlySeekCompleted at VideoOnlySeekingState::Exit(); r?jwwang
MozReview-Commit-ID: A8PzfUpJjao
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1749,23 +1749,20 @@ public:
// changes.
mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekBegin);
return p.forget();
}
void Exit() override
{
- if (mSeekJob.Exists() &&
- mSeekJob.mTarget.isSome()) {
- // We are discarding this video-only seek operation now, and we still need
- // to dispatch an event so that the UI can change in response to the end
- // of video-only seek.
- mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
- }
+ // We are completing or discarding this video-only seek operation now,
+ // dispatch an event so that the UI can change in response to the end
+ // of video-only seek.
+ mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
AccurateSeekingState::Exit();
}
void HandleAudioDecoded(AudioData* aAudio) override
{
MOZ_ASSERT(mDoneAudioSeeking && !mDoneVideoSeeking,
"Seek shouldn't be finished");
@@ -2496,21 +2493,20 @@ SeekingState::SeekCompleted()
mMaster->mVideoCompleted = true;
// There might still be a pending audio request when doing video-only or
// next-frame seek. Discard it so we won't break the invariants of the
// COMPLETED state by adding audio samples to a finished queue.
mMaster->mAudioDataRequest.DisconnectIfExists();
}
- // Cache mTarget for mSeekJob.Resolve() below will reset it.
- SeekTarget target = mSeekJob.mTarget.ref();
-
// We want to resolve the seek request prior finishing the first frame
// to ensure that the seeked event is fired prior loadeded.
+ // Note: SeekJob.Resolve() resets SeekJob.mTarget. Don't use mSeekJob anymore
+ // hereafter.
mSeekJob.Resolve(__func__);
// Notify FirstFrameLoaded now if we haven't since we've decoded some data
// for readyState to transition to HAVE_CURRENT_DATA and fire 'loadeddata'.
if (!mMaster->mSentFirstFrameLoadedEvent) {
mMaster->FinishDecodeFirstFrame();
}
@@ -2521,22 +2517,16 @@ SeekingState::SeekCompleted()
// request is from the user.
if (mVisibility == EventVisibility::Observable) {
// Don't update playback position for video-only seek.
// Otherwise we might have |newCurrentTime > mMediaSink->GetPosition()|
// and fail the assertion in GetClock() since we didn't stop MediaSink.
mMaster->UpdatePlaybackPositionInternal(newCurrentTime);
}
- // Dispatch an event so that the UI can change in response to the end of
- // video-only seek
- if (target.IsVideoOnly()) {
- mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekCompleted);
- }
-
// Try to decode another frame to detect if we're at the end...
SLOG("Seek completed, mCurrentPosition=%" PRId64,
mMaster->mCurrentPosition.Ref().ToMicroseconds());
if (mMaster->VideoQueue().PeekFront()) {
mMaster->mMediaSink->Redraw(Info().mVideo);
mMaster->mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
}