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

Commit 8ceef4d1 authored by Sungtak Lee's avatar Sungtak Lee
Browse files

CCodecBufferChannel: Report an error after reallocation failures

Output buffer conversion failures trigger endless reallocations of
output buffers. Report an error in the case.

Bug: 235610661
Bug: 236087159
Change-Id: Id2b6a25f4fdfa244dc64b15fc19c2fa899a61bae
parent f9591d6b
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);