Bug 828901 - Get the seek time as mBasePosition instead of the stream position in video-only stream when changing the playbackRate and seeking at the same time. r=kinetik

This commit is contained in:
Paul Adenot 2013-01-15 19:57:03 +01:00
parent 866ba5a7d9
commit 0e6d22d211

View File

@ -2268,11 +2268,8 @@ int64_t MediaDecoderStateMachine::GetVideoStreamPosition()
int64_t pos = DurationToUsecs(TimeStamp::Now() - mPlayStartTime) + mPlayDuration;
pos -= mBasePosition;
if (pos >= 0) {
int64_t final = mBasePosition + pos * mPlaybackRate + mStartTime;
return final;
}
return mPlayDuration + mStartTime;
NS_ASSERTION(pos >= 0, "Video stream position should be positive.");
return mBasePosition + pos * mPlaybackRate + mStartTime;
}
int64_t MediaDecoderStateMachine::GetClock() {
@ -2731,12 +2728,14 @@ void MediaDecoderStateMachine::SetPlaybackRate(double aPlaybackRate)
// Get position of the last time we changed the rate.
if (!HasAudio()) {
// mBasePosition is a position in the video stream, not an absolute time.
mBasePosition = GetVideoStreamPosition();
if (IsPlaying()) {
mPlayDuration = mBasePosition - mStartTime;
mResetPlayStartTime = true;
mPlayStartTime = TimeStamp::Now();
if (mState == DECODER_STATE_SEEKING) {
mBasePosition = mSeekTime;
} else {
mBasePosition = GetVideoStreamPosition();
}
mPlayDuration = mBasePosition - mStartTime;
mResetPlayStartTime = true;
mPlayStartTime = TimeStamp::Now();
}
mPlaybackRate = aPlaybackRate;