Loading media/libstagefright/AwesomePlayer.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -1863,6 +1863,7 @@ void AwesomePlayer::onVideoEvent() { ((mFlags & AUDIO_AT_EOS) || !(mFlags & AUDIOPLAYER_STARTED)) ? &mSystemTimeSource : mTimeSource; int64_t systemTimeUs = mSystemTimeSource.getRealTimeUs(); int64_t looperTimeUs = ALooper::GetNowUs(); if (mFlags & FIRST_FRAME) { modifyFlags(FIRST_FRAME, CLEAR); Loading Loading @@ -1893,12 +1894,13 @@ void AwesomePlayer::onVideoEvent() { } } int64_t latenessUs = 0; if (wasSeeking == NO_SEEK) { // Let's display the first frame after seeking right away. int64_t nowUs = estimateRealTimeUs(ts, systemTimeUs) - mTimeSourceDeltaUs; int64_t latenessUs = nowUs - timeUs; latenessUs = nowUs - timeUs; ATRACE_INT("Video Lateness (ms)", latenessUs / 1E3); Loading Loading @@ -1952,10 +1954,9 @@ void AwesomePlayer::onVideoEvent() { } } if (latenessUs < -10000) { // We're more than 10ms early. Try to schedule at least 12ms // early (to hit this same check), or just on time. postVideoEvent_l(latenessUs < -22000 ? 10000 : -latenessUs); if (latenessUs < -30000) { // We're more than 30ms early, schedule at most 20 ms before time due postVideoEvent_l(latenessUs < -60000 ? 30000 : -latenessUs - 20000); return; } } Loading @@ -1969,6 +1970,8 @@ void AwesomePlayer::onVideoEvent() { if (mVideoRenderer != NULL) { mSinceLastDropped++; mVideoBuffer->meta_data()->setInt64(kKeyTime, looperTimeUs - latenessUs); mVideoRenderer->render(mVideoBuffer); if (!mVideoRenderingStarted) { mVideoRenderingStarted = true; Loading Loading @@ -2022,8 +2025,8 @@ void AwesomePlayer::onVideoEvent() { int64_t delayUs = nextTimeUs - estimateRealTimeUs(ts, systemTimeUs) + mTimeSourceDeltaUs; ATRACE_INT("Frame delta (ms)", (nextTimeUs - timeUs) / 1E3); ALOGV("next frame in %" PRId64, delayUs); // try to schedule at least 12ms before due time, or just on time postVideoEvent_l(delayUs > 22000 ? 10000 : delayUs < 0 ? 0 : delayUs); // try to schedule 30ms before time due postVideoEvent_l(delayUs > 60000 ? 30000 : (delayUs < 30000 ? 0 : delayUs - 30000)); return; } Loading Loading
media/libstagefright/AwesomePlayer.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -1863,6 +1863,7 @@ void AwesomePlayer::onVideoEvent() { ((mFlags & AUDIO_AT_EOS) || !(mFlags & AUDIOPLAYER_STARTED)) ? &mSystemTimeSource : mTimeSource; int64_t systemTimeUs = mSystemTimeSource.getRealTimeUs(); int64_t looperTimeUs = ALooper::GetNowUs(); if (mFlags & FIRST_FRAME) { modifyFlags(FIRST_FRAME, CLEAR); Loading Loading @@ -1893,12 +1894,13 @@ void AwesomePlayer::onVideoEvent() { } } int64_t latenessUs = 0; if (wasSeeking == NO_SEEK) { // Let's display the first frame after seeking right away. int64_t nowUs = estimateRealTimeUs(ts, systemTimeUs) - mTimeSourceDeltaUs; int64_t latenessUs = nowUs - timeUs; latenessUs = nowUs - timeUs; ATRACE_INT("Video Lateness (ms)", latenessUs / 1E3); Loading Loading @@ -1952,10 +1954,9 @@ void AwesomePlayer::onVideoEvent() { } } if (latenessUs < -10000) { // We're more than 10ms early. Try to schedule at least 12ms // early (to hit this same check), or just on time. postVideoEvent_l(latenessUs < -22000 ? 10000 : -latenessUs); if (latenessUs < -30000) { // We're more than 30ms early, schedule at most 20 ms before time due postVideoEvent_l(latenessUs < -60000 ? 30000 : -latenessUs - 20000); return; } } Loading @@ -1969,6 +1970,8 @@ void AwesomePlayer::onVideoEvent() { if (mVideoRenderer != NULL) { mSinceLastDropped++; mVideoBuffer->meta_data()->setInt64(kKeyTime, looperTimeUs - latenessUs); mVideoRenderer->render(mVideoBuffer); if (!mVideoRenderingStarted) { mVideoRenderingStarted = true; Loading Loading @@ -2022,8 +2025,8 @@ void AwesomePlayer::onVideoEvent() { int64_t delayUs = nextTimeUs - estimateRealTimeUs(ts, systemTimeUs) + mTimeSourceDeltaUs; ATRACE_INT("Frame delta (ms)", (nextTimeUs - timeUs) / 1E3); ALOGV("next frame in %" PRId64, delayUs); // try to schedule at least 12ms before due time, or just on time postVideoEvent_l(delayUs > 22000 ? 10000 : delayUs < 0 ? 0 : delayUs); // try to schedule 30ms before time due postVideoEvent_l(delayUs > 60000 ? 30000 : (delayUs < 30000 ? 0 : delayUs - 30000)); return; } Loading