Bug 1128069: [MSE] P5. Adjust currentTime to end position in MediaDecoder. r?jwwang
The duration in the MediaDecoder is the canonical. It has as such a more up to date value than the mirror.
Under some circumstances, the MDSM may have reached the end of media playback before the duration mirror had time to update. So perform the currentTime adjustment in the MediaDecoder instead.
MozReview-Commit-ID: 1RFr4mT5LpA
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1359,16 +1359,19 @@ MediaDecoder::ChangeState(PlayState aSta
void
MediaDecoder::UpdateLogicalPositionInternal(MediaDecoderEventVisibility aEventVisibility)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsShutdown());
double currentPosition = static_cast<double>(CurrentPosition()) / static_cast<double>(USECS_PER_S);
+ if (mPlayState == PLAY_STATE_ENDED) {
+ currentPosition = std::max(currentPosition, mDuration);
+ }
bool logicalPositionChanged = mLogicalPosition != currentPosition;
mLogicalPosition = currentPosition;
// Invalidate the frame so any video data is displayed.
// Do this before the timeupdate event so that if that
// event runs JavaScript that queries the media size, the
// frame has reflowed and the size updated beforehand.
Invalidate();