Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2314088 authored by Lajos Molnar's avatar Lajos Molnar Committed by Gerrit Code Review
Browse files

Merge "AwesomePlayer: use PTS for queueBuffer"

parents b52675e9 a6e6c70a
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -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;
    }