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

Commit 56097a8e authored by Wei Jia's avatar Wei Jia
Browse files

NuPlayerDecoder: fail gracefully when input data can't be held in allocated buffer.

Bug: 24145279
Change-Id: I6b99ee2dc63063557f4ee2c5856f7c848e969752
parent 987f9532
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -525,7 +525,10 @@ bool NuPlayer::Decoder::handleAnInputBuffer(size_t index) {
        ALOGI("[%s] resubmitting CSD", mComponentName.c_str());
        msg->setBuffer("buffer", buffer);
        mCSDsToSubmit.removeAt(0);
        CHECK(onInputBufferFetched(msg));
        if (!onInputBufferFetched(msg)) {
            handleError(UNKNOWN_ERROR);
            return false;
        }
        return true;
    }

@@ -862,7 +865,11 @@ bool NuPlayer::Decoder::onInputBufferFetched(const sp<AMessage> &msg) {

        // copy into codec buffer
        if (buffer != codecBuffer) {
            CHECK_LE(buffer->size(), codecBuffer->capacity());
            if (buffer->size() > codecBuffer->capacity()) {
                handleError(ERROR_BUFFER_TOO_SMALL);
                mDequeuedInputBuffers.push_back(bufferIx);
                return false;
            }
            codecBuffer->setRange(0, buffer->size());
            memcpy(codecBuffer->data(), buffer->data(), buffer->size());
        }