summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2014-04-30 10:19:40 -0700
committerLajos Molnar <lajos@google.com>2014-05-01 20:21:08 -0700
commita6e6c70a3c5403e178741eee20c7742e736c4818 (patch)
tree05a422073abe20fe7cba9d63b127de2545442254 /media/libstagefright
parent1b78c4b1484c7d4c12b9a87329dc8d4b6e8c0c37 (diff)
downloadframeworks_av-a6e6c70a3c5403e178741eee20c7742e736c4818.zip
frameworks_av-a6e6c70a3c5403e178741eee20c7742e736c4818.tar.gz
frameworks_av-a6e6c70a3c5403e178741eee20c7742e736c4818.tar.bz2
AwesomePlayer: use PTS for queueBuffer
Change-Id: I1c14ad4784c799c46cf06a14b0f00c5e4d01f718
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/AwesomePlayer.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index e66ccd9..ea6c15b 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -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);
@@ -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);
@@ -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;
}
}
@@ -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;
@@ -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;
}