Bug 943461. Part 15: Make MediaDecoder set its currentTime based on the decoded stream's time directly, if we are decoding to a stream. r=cpearce

--HG--
extra : rebase_source : 35fe51dbec3107d7dae801a5a179c5ef5fa53725
This commit is contained in:
Robert O'Callahan 2013-12-13 01:33:00 +13:00
parent b33d4283d0
commit 81d72a6306
3 changed files with 17 additions and 4 deletions

View File

@ -1283,7 +1283,12 @@ void MediaDecoder::PlaybackPositionChanged()
// and we don't want to override the seek algorithm and change the
// current time after the seek has started but before it has
// completed.
mCurrentTime = mDecoderStateMachine->GetCurrentTime();
if (GetDecodedStream()) {
mCurrentTime = mDecoderStateMachine->GetCurrentTimeViaMediaStreamSync()/
static_cast<double>(USECS_PER_S);
} else {
mCurrentTime = mDecoderStateMachine->GetCurrentTime();
}
}
mDecoderStateMachine->ClearPositionChangeFlag();
}

View File

@ -1336,6 +1336,15 @@ void MediaDecoderStateMachine::SetSyncPointForMediaStream()
mSyncPointInDecodedStream = mStartTime + mPlayDuration;
}
int64_t MediaDecoderStateMachine::GetCurrentTimeViaMediaStreamSync()
{
AssertCurrentThreadInMonitor();
NS_ASSERTION(mSyncPointInDecodedStream >= 0, "Should have set up sync point");
DecodedStreamData* stream = mDecoder->GetDecodedStream();
StreamTime streamDelta = stream->GetLastOutputTime() - mSyncPointInMediaStream;
return mSyncPointInDecodedStream + MediaTimeToMicroseconds(streamDelta);
}
void MediaDecoderStateMachine::StartPlayback()
{
DECODER_LOG(PR_LOG_DEBUG, ("%p StartPlayback()", mDecoder.get()));
@ -2461,9 +2470,7 @@ int64_t MediaDecoderStateMachine::GetClock() {
if (!IsPlaying()) {
clock_time = mPlayDuration + mStartTime;
} else if (stream) {
NS_ASSERTION(mSyncPointInDecodedStream >= 0, "Should have set up sync point");
StreamTime streamDelta = stream->GetLastOutputTime() - mSyncPointInMediaStream;
clock_time = mSyncPointInDecodedStream + MediaTimeToMicroseconds(streamDelta);
clock_time = GetCurrentTimeViaMediaStreamSync();
} else {
int64_t audio_time = GetAudioClock();
if (HasAudio() && !mAudioCompleted && audio_time != -1) {

View File

@ -334,6 +334,7 @@ public:
// call this while we're not playing (while the MediaStream is blocked). Can
// be called on any thread with the decoder monitor held.
void SetSyncPointForMediaStream();
int64_t GetCurrentTimeViaMediaStreamSync();
// Called when a "MozAudioAvailable" event listener is added to the media
// element. Called on the main thread.