Bug 1378085 P8 - don't update playback position in video-only seeking; r?jwwang
MozReview-Commit-ID: JPsZ4L8b3g
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -970,17 +970,17 @@ public:
mMaster->mOnPlaybackEvent.Notify(MediaEventType::ExitVideoSuspend);
Reader()->SetVideoBlankDecode(false);
}
NotifyVideoOnlySeekBegin();
StopPlayback();
- mMaster->UpdatePlaybackPositionInternal(mSeekJob.mTarget->GetTime());
+ UpdatePlaybackPosition(mSeekJob.mTarget->GetTime());
if (aVisibility == EventVisibility::Observable) {
mMaster->mOnPlaybackEvent.Notify(MediaEventType::SeekStarted);
// We want dormant actions to be transparent to the user.
// So we only notify the change when the seek request is from the user.
mMaster->UpdateNextFrameStatus(
MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING);
}
@@ -1021,16 +1021,20 @@ protected:
virtual void NotifyVideoOnlySeekBegin() {}
virtual void StopPlayback() { mMaster->StopPlayback(); }
virtual void DoSeek() = 0;
// Transition to the next state (defined by the subclass) when seek is completed.
virtual void GoToNextState() { SetState<DecodingState>(); }
void SeekCompleted();
virtual TimeUnit CalculateNewCurrentTime() const = 0;
+ virtual void UpdatePlaybackPosition(const TimeUnit& aTime)
+ {
+ mMaster->UpdatePlaybackPositionInternal(aTime);
+ }
};
class MediaDecoderStateMachine::AccurateSeekingState
: public MediaDecoderStateMachine::SeekingState
{
public:
explicit AccurateSeekingState(Master* aPtr) : SeekingState(aPtr) { }
@@ -1804,16 +1808,19 @@ private:
// changes.
void NotifyVideoOnlySeekBegin() override
{
mMaster->mOnPlaybackEvent.Notify(MediaEventType::VideoOnlySeekBegin);
}
// Don't stop playback for a video-only seek since audio is playing.
void StopPlayback() override { }
+
+ // Don't update the media time since we did not stop the playback.
+ void UpdatePlaybackPosition(const TimeUnit&) override { }
};
RefPtr<MediaDecoder::SeekPromise>
MediaDecoderStateMachine::DormantState::HandleSeek(SeekTarget aTarget)
{
if (aTarget.IsNextFrame()) {
// NextFrameSeekingState doesn't reset the decoder unlike
// AccurateSeekingState. So we first must come out of dormant by seeking to
@@ -2517,22 +2524,20 @@ SeekingState::SeekCompleted()
// 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();
}
// Ensure timestamps are up to date.
- if (!target.IsVideoOnly()) {
- // 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);
- }
+ // 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.
+ UpdatePlaybackPosition(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...