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

Commit a49d3c53 authored by ot900339's avatar ot900339 Committed by Dorin Drimus
Browse files

Fix MediaCodec mBuffersInFlight size increased so large

Mediacodec mBuffersInFlight size only increase without
decrease when play most of netflix 4k videos for 20 mins

Test: Netflix playback OK

Bug: 296353551
Change-Id: Ifa2cbfba59ee32507bc565d0a5053cecdf79b274
parent 60cbc2b5
Loading
Loading
Loading
Loading
+11 −13
Original line number Original line Diff line number Diff line
@@ -1607,24 +1607,22 @@ void MediaCodec::statsBufferSent(int64_t presentationUs, const sp<MediaCodecBuff
        mFramesInput++;
        mFramesInput++;
    }
    }


    const int64_t nowNs = systemTime(SYSTEM_TIME_MONOTONIC);
    BufferFlightTiming_t startdata = { presentationUs, nowNs };

    {
    // mutex access to mBuffersInFlight and other stats
    // mutex access to mBuffersInFlight and other stats
    Mutex::Autolock al(mLatencyLock);
    Mutex::Autolock al(mLatencyLock);



    // XXX: we *could* make sure that the time is later than the end of queue
    // XXX: we *could* make sure that the time is later than the end of queue
    // as part of a consistency check...
    // as part of a consistency check...
    if (!mTunneled) {
        const int64_t nowNs = systemTime(SYSTEM_TIME_MONOTONIC);
        BufferFlightTiming_t startdata = { presentationUs, nowNs };
        mBuffersInFlight.push_back(startdata);
        mBuffersInFlight.push_back(startdata);
    }


    if (mIsLowLatencyModeOn && mIndexOfFirstFrameWhenLowLatencyOn < 0) {
    if (mIsLowLatencyModeOn && mIndexOfFirstFrameWhenLowLatencyOn < 0) {
        mIndexOfFirstFrameWhenLowLatencyOn = mInputBufferCounter;
        mIndexOfFirstFrameWhenLowLatencyOn = mInputBufferCounter;
    }
    }
    ++mInputBufferCounter;
    ++mInputBufferCounter;
}
}
}


// when we get a buffer back from the codec
// when we get a buffer back from the codec
void MediaCodec::statsBufferReceived(int64_t presentationUs, const sp<MediaCodecBuffer> &buffer) {
void MediaCodec::statsBufferReceived(int64_t presentationUs, const sp<MediaCodecBuffer> &buffer) {