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

Commit da5a24f1 authored by Krishnankutty Kolathappilly's avatar Krishnankutty Kolathappilly Committed by Ricardo Cerqueira
Browse files

libstagefright: Fix for FPS drop issue during A-V playback.

Issues:
-The AAC decoder was not updating the timestamp when EOS is reached.
-Logic to smoothen the real time update in AudioPlayer uses system
 time. This introduces corrupt timestamp during EOS.

Fix:
-Update the timestamp in AAC decoder when EOS is reached.
-Extrapolate realtime using system time in AudioPlayer when EOS is
 reached. Cap the value to realtime if  extrapolated time becomes greater
 than realtime.

CRs-Fixed: 384183 515066
Change-Id: Ice54501436431d2527fcd3d710d65d9732fcffdd
parent 6d327d5e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -668,11 +668,11 @@ size_t AudioPlayer::fillBuffer(void *data, size_t size) {
    {
        Mutex::Autolock autoLock(mLock);
        mNumFramesPlayed += size_done / mFrameSize;
        mNumFramesPlayedSysTimeUs = ALooper::GetNowUs();

        if (mReachedEOS) {
            mPinnedTimeUs = mNumFramesPlayedSysTimeUs;
        } else {
            mNumFramesPlayedSysTimeUs = ALooper::GetNowUs();
            mPinnedTimeUs = -1ll;
        }
    }
@@ -711,14 +711,21 @@ int64_t AudioPlayer::getRealTimeUsLocked() const {
    // compensate using system time.
    int64_t diffUs;
    if (mPinnedTimeUs >= 0ll) {
        if(mReachedEOS)
            diffUs = ALooper::GetNowUs();
        else
            diffUs = mPinnedTimeUs;

    } else {
        diffUs = ALooper::GetNowUs();
    }

    diffUs -= mNumFramesPlayedSysTimeUs;

    if(result + diffUs <= mPositionTimeRealUs)
        return result + diffUs;
    else
        return mPositionTimeRealUs;
}

int64_t AudioPlayer::getOutputPlayPositionUs_l() const
+3 −0
Original line number Diff line number Diff line
@@ -399,6 +399,9 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
            }

            outHeader->nFlags = OMX_BUFFERFLAG_EOS;
            outHeader->nTimeStamp =
                mAnchorTimeUs
                    + (mNumSamplesOutput * 1000000ll) / mStreamInfo->sampleRate;

            outQueue.erase(outQueue.begin());
            outInfo->mOwnedByUs = false;