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

Commit 5b33db05 authored by Sungtak Lee's avatar Sungtak Lee Committed by Android (Google) Code Review
Browse files

Merge "CCodecBufferChannel: Report an error after reallocation failures" into tm-dev

parents 96368f07 8ceef4d1
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2041,6 +2041,9 @@ void CCodecBufferChannel::sendOutputBuffers() {
    sp<MediaCodecBuffer> outBuffer;
    std::shared_ptr<C2Buffer> c2Buffer;

    constexpr int kMaxReallocTry = 5;
    int reallocTryNum = 0;

    while (true) {
        Mutexed<Output>::Locked output(mOutput);
        if (!output->buffers) {
@@ -2048,6 +2051,9 @@ void CCodecBufferChannel::sendOutputBuffers() {
        }
        action = output->buffers->popFromStashAndRegister(
                &c2Buffer, &index, &outBuffer);
        if (action != OutputBuffers::REALLOCATE) {
            reallocTryNum = 0;
        }
        switch (action) {
        case OutputBuffers::SKIP:
            return;
@@ -2058,6 +2064,13 @@ void CCodecBufferChannel::sendOutputBuffers() {
            mCallback->onOutputBufferAvailable(index, outBuffer);
            break;
        case OutputBuffers::REALLOCATE:
            if (++reallocTryNum > kMaxReallocTry) {
                output.unlock();
                ALOGE("[%s] sendOutputBuffers: tried %d realloc and failed",
                          mName, kMaxReallocTry);
                mCCodecCallback->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
                return;
            }
            if (!output->buffers->isArrayMode()) {
                output->buffers =
                    output->buffers->toArrayMode(output->numSlots);