Bug 1193124 - ensure logical position is updated after seek. r=jwwang.
MozReview-Commit-ID: KD4ylXbaDfu
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1246,17 +1246,18 @@ MediaDecoder::OnSeekResolved(SeekResolve
UnpinForSeek();
fireEnded = aVal.mAtEnd;
if (aVal.mAtEnd) {
ChangeState(PLAY_STATE_ENDED);
}
mLogicallySeeking = false;
}
- UpdateLogicalPosition(aVal.mEventVisibility);
+ // Ensure logical position is updated after seek.
+ UpdateLogicalPositionInternal(aVal.mEventVisibility);
if (aVal.mEventVisibility != MediaDecoderEventVisibility::Suppressed) {
mOwner->SeekCompleted();
if (fireEnded) {
mOwner->PlaybackEnded();
}
}
}
@@ -1297,24 +1298,20 @@ MediaDecoder::ChangeState(PlayState aSta
}
CancelDormantTimer();
// Start dormant timer if necessary
StartDormantTimer();
}
void
-MediaDecoder::UpdateLogicalPosition(MediaDecoderEventVisibility aEventVisibility)
+MediaDecoder::UpdateLogicalPositionInternal(MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
- if (mShuttingDown)
- return;
-
- // Per spec, offical position remains stable during pause and seek.
- if (mPlayState == PLAY_STATE_PAUSED || IsSeeking()) {
+ if (mShuttingDown) {
return;
}
double currentPosition = static_cast<double>(CurrentPosition()) / static_cast<double>(USECS_PER_S);
bool logicalPositionChanged = mLogicalPosition != currentPosition;
mLogicalPosition = currentPosition;
// Invalidate the frame so any video data is displayed.
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -406,21 +406,25 @@ private:
MOZ_ASSERT(NS_IsMainThread());
mIgnoreProgressData = mLogicallySeeking;
}
// Seeking has started. Inform the element on the main
// thread.
void SeekingStarted(MediaDecoderEventVisibility aEventVisibility = MediaDecoderEventVisibility::Observable);
- void UpdateLogicalPosition(MediaDecoderEventVisibility aEventVisibility);
+ void UpdateLogicalPositionInternal(MediaDecoderEventVisibility aEventVisibility);
void UpdateLogicalPosition()
{
MOZ_ASSERT(NS_IsMainThread());
- UpdateLogicalPosition(MediaDecoderEventVisibility::Observable);
+ // Per spec, offical position remains stable during pause and seek.
+ if (mPlayState == PLAY_STATE_PAUSED || IsSeeking()) {
+ return;
+ }
+ UpdateLogicalPositionInternal(MediaDecoderEventVisibility::Observable);
}
// Find the end of the cached data starting at the current decoder
// position.
int64_t GetDownloadPosition();
// Notifies the element that decoding has failed.
void DecodeError();