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

Commit 2df921d0 authored by Zhijun He's avatar Zhijun He Committed by Android (Google) Code Review
Browse files

Merge "camera2/3: Add protection for still capture path"

parents a10431fb 138851bd
Loading
Loading
Loading
Loading
+44 −35
Original line number Diff line number Diff line
@@ -200,9 +200,17 @@ status_t JpegProcessor::processNewCapture() {
    ATRACE_CALL();
    status_t res;
    sp<Camera2Heap> captureHeap;
    sp<MemoryBase> captureBuffer;

    CpuConsumer::LockedBuffer imgBuffer;

    {
        Mutex::Autolock l(mInputMutex);
        if (mCaptureStreamId == NO_STREAM) {
            ALOGW("%s: Camera %d: No stream is available", __FUNCTION__, mId);
            return INVALID_OPERATION;
        }

        res = mCaptureConsumer->lockNextBuffer(&imgBuffer);
        if (res != OK) {
            if (res != BAD_VALUE) {
@@ -239,11 +247,12 @@ status_t JpegProcessor::processNewCapture() {
        }

        // TODO: Optimize this to avoid memcopy
    sp<MemoryBase> captureBuffer = new MemoryBase(mCaptureHeap, 0, jpegSize);
        captureBuffer = new MemoryBase(mCaptureHeap, 0, jpegSize);
        void* captureMemory = mCaptureHeap->getBase();
        memcpy(captureMemory, imgBuffer.data, jpegSize);

        mCaptureConsumer->unlockBuffer(imgBuffer);
    }

    sp<CaptureSequencer> sequencer = mSequencer.promote();
    if (sequencer != 0) {