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

Commit bd060b59 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."

am: 80b99139

* commit '80b99139':
  NuPlayerRenderer: always display the first video frame without delay.
parents 674649bc 80b99139
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1042,6 +1042,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);
            }
@@ -1102,7 +1105,7 @@ void NuPlayer::Renderer::onDrainVideoQueue() {
        return;
    }

    int64_t nowUs = -1;
    int64_t nowUs = ALooper::GetNowUs();
    int64_t realTimeUs;
    if (mFlags & FLAG_REAL_TIME) {
        CHECK(entry->mBuffer->meta()->findInt64("timeUs", &realTimeUs));
@@ -1110,16 +1113,12 @@ void NuPlayer::Renderer::onDrainVideoQueue() {
        int64_t mediaTimeUs;
        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);

@@ -1143,6 +1142,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();