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

Commit dc123cba authored by Wei Jia's avatar Wei Jia Committed by android-build-merger
Browse files

Merge "NuPlayerRenderer: always display the first video frame without delay."...

Merge "NuPlayerRenderer: always display the first video frame without delay." am: 80b99139 am: bd060b59
am: caf17eb5

* commit 'caf17eb5':
  NuPlayerRenderer: always display the first video frame without delay.
parents 6411cb68 caf17eb5
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1088,6 +1088,9 @@ void NuPlayer::Renderer::postDrainVideoQueue() {
                mMediaClock->updateAnchor(mediaTimeUs, nowUs, mediaTimeUs);
                mAnchorTimeMediaUs = mediaTimeUs;
                realTimeUs = nowUs;
            } else if (!mVideoSampleReceived) {
                // Always render the first video frame.
                realTimeUs = nowUs;
            } else {
                realTimeUs = getRealTimeUs(mediaTimeUs, nowUs);
            }
@@ -1148,7 +1151,7 @@ void NuPlayer::Renderer::onDrainVideoQueue() {
        return;
    }

    int64_t nowUs = -1;
    int64_t nowUs = ALooper::GetNowUs();
    int64_t realTimeUs;
    int64_t mediaTimeUs = -1;
    if (mFlags & FLAG_REAL_TIME) {
@@ -1156,16 +1159,12 @@ void NuPlayer::Renderer::onDrainVideoQueue() {
    } else {
        CHECK(entry->mBuffer->meta()->findInt64("timeUs", &mediaTimeUs));

        nowUs = ALooper::GetNowUs();
        realTimeUs = getRealTimeUs(mediaTimeUs, nowUs);
    }

    bool tooLate = false;

    if (!mPaused) {
        if (nowUs == -1) {
            nowUs = ALooper::GetNowUs();
        }
        setVideoLateByUs(nowUs - realTimeUs);
        tooLate = (mVideoLateByUs > 40000);

@@ -1197,6 +1196,12 @@ void NuPlayer::Renderer::onDrainVideoQueue() {
        }
    }

    // Always render the first video frame while keeping stats on A/V sync.
    if (!mVideoSampleReceived) {
        realTimeUs = nowUs;
        tooLate = false;
    }

    entry->mNotifyConsumed->setInt64("timestampNs", realTimeUs * 1000ll);
    entry->mNotifyConsumed->setInt32("render", !tooLate);
    entry->mNotifyConsumed->post();