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

Commit 47afcc5f authored by Lajos Molnar's avatar Lajos Molnar Committed by Android Git Automerger
Browse files

am 069bcc50: Merge "AwesomePlayer: Improve performance on high-fps clips" into klp-dev

* commit '069bcc50':
  AwesomePlayer: Improve performance on high-fps clips
parents 0e0278e3 069bcc50
Loading
Loading
Loading
Loading
+36 −1
Original line number Diff line number Diff line
@@ -1931,7 +1931,7 @@ void AwesomePlayer::onVideoEvent() {
                    ++mStats.mNumVideoFramesDropped;
                }

                postVideoEvent_l();
                postVideoEvent_l(0);
                return;
            }
        }
@@ -1971,6 +1971,41 @@ void AwesomePlayer::onVideoEvent() {
        return;
    }

    /* get next frame time */
    if (wasSeeking == NO_SEEK) {
        MediaSource::ReadOptions options;
        for (;;) {
            status_t err = mVideoSource->read(&mVideoBuffer, &options);
            if (err != OK) {
                // deal with any errors next time
                CHECK(mVideoBuffer == NULL);
                postVideoEvent_l(0);
                return;
            }

            if (mVideoBuffer->range_length() != 0) {
                break;
            }

            // Some decoders, notably the PV AVC software decoder
            // return spurious empty buffers that we just want to ignore.

            mVideoBuffer->release();
            mVideoBuffer = NULL;
        }

        {
            Mutex::Autolock autoLock(mStatsLock);
            ++mStats.mNumVideoFramesDecoded;
        }

        int64_t nextTimeUs;
        CHECK(mVideoBuffer->meta_data()->findInt64(kKeyTime, &nextTimeUs));
        int64_t delayUs = nextTimeUs - ts->getRealTimeUs() + mTimeSourceDeltaUs;
        postVideoEvent_l(delayUs > 10000 ? 10000 : delayUs < 0 ? 0 : delayUs);
        return;
    }

    postVideoEvent_l();
}