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

Commit 8818bf1f authored by Wei Jia's avatar Wei Jia
Browse files

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

Bug: 38391487
Bug: 24145279
Change-Id: I6b99ee2dc63063557f4ee2c5856f7c848e969752
(cherry picked from commit 56097a8e)
parent 1f7d8077
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -276,7 +276,10 @@ bool NuPlayer::Decoder::handleAnInputBuffer() {
        ALOGI("[%s] resubmitting CSD", mComponentName.c_str());
        reply->setBuffer("buffer", buffer);
        mCSDsToSubmit.removeAt(0);
        CHECK(onInputBufferFilled(reply));
        if (!onInputBufferFilled(reply)) {
            handleError(UNKNOWN_ERROR);
            return false;
        }
        return true;
    }

@@ -389,7 +392,10 @@ bool android::NuPlayer::Decoder::onInputBufferFilled(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);
                return false;
            }
            codecBuffer->setRange(0, buffer->size());
            memcpy(codecBuffer->data(), buffer->data(), buffer->size());
        }