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

Commit 7c77c75d authored by Chien-Yu Chen's avatar Chien-Yu Chen Committed by Android (Google) Code Review
Browse files

Merge "Camera2Device: fix camera metadata leaks" into lmp-mr1-dev

parents 538596f7 80de5dca
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -793,11 +793,6 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(camera_metadata_t *buf)
        mStreamSlotCount = 0;
        return OK;
    }
    camera_metadata_t *buf2 = clone_camera_metadata(buf);
    if (!buf2) {
        ALOGE("%s: Unable to clone metadata buffer!", __FUNCTION__);
        return NO_MEMORY;
    }

    if (mStreamSlotCount > 1) {
        List<camera_metadata_t*>::iterator deleter = ++mStreamSlot.begin();
@@ -806,9 +801,9 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(camera_metadata_t *buf)
    }
    if (mStreamSlotCount == 1) {
        free_camera_metadata( *(mStreamSlot.begin()) );
        *(mStreamSlot.begin()) = buf2;
        *(mStreamSlot.begin()) = buf;
    } else {
        mStreamSlot.push_front(buf2);
        mStreamSlot.push_front(buf);
        mStreamSlotCount = 1;
    }
    return signalConsumerLocked();
@@ -827,12 +822,7 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(
    mStreamSlotCount = 0;
    for (List<camera_metadata_t*>::const_iterator r = bufs.begin();
         r != bufs.end(); r++) {
        camera_metadata_t *r2 = clone_camera_metadata(*r);
        if (!r2) {
            ALOGE("%s: Unable to clone metadata buffer!", __FUNCTION__);
            return NO_MEMORY;
        }
        mStreamSlot.push_back(r2);
        mStreamSlot.push_back(*r);
        mStreamSlotCount++;
    }
    return signalConsumerLocked();
+2 −2
Original line number Diff line number Diff line
@@ -124,8 +124,8 @@ class Camera2Device: public CameraDeviceBase {

        // Set repeating buffer(s); if the queue is empty on a dequeue call, the
        // queue copies the contents of the stream slot into the queue, and then
        // dequeues the first new entry. The metadata buffers passed in are
        // copied.
        // dequeues the first new entry. The methods take the ownership of the
        // metadata buffers passed in.
        status_t setStreamSlot(camera_metadata_t *buf);
        status_t setStreamSlot(const List<camera_metadata_t*> &bufs);