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

Commit a9300fd3 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Android (Google) Code Review
Browse files

Merge "Camera2: Copy metadata buffers for streaming."

parents 0e0dc7a6 6ed1ed1b
Loading
Loading
Loading
Loading
+21 −4
Original line number Original line Diff line number Diff line
@@ -302,6 +302,12 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(camera_metadata_t *buf)
        mStreamSlotCount = 0;
        mStreamSlotCount = 0;
        return OK;
        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) {
    if (mStreamSlotCount > 1) {
        List<camera_metadata_t*>::iterator deleter = ++mStreamSlot.begin();
        List<camera_metadata_t*>::iterator deleter = ++mStreamSlot.begin();
        freeBuffers(++mStreamSlot.begin(), mStreamSlot.end());
        freeBuffers(++mStreamSlot.begin(), mStreamSlot.end());
@@ -309,9 +315,9 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(camera_metadata_t *buf)
    }
    }
    if (mStreamSlotCount == 1) {
    if (mStreamSlotCount == 1) {
        free_camera_metadata( *(mStreamSlot.begin()) );
        free_camera_metadata( *(mStreamSlot.begin()) );
        *(mStreamSlot.begin()) = buf;
        *(mStreamSlot.begin()) = buf2;
    } else {
    } else {
        mStreamSlot.push_front(buf);
        mStreamSlot.push_front(buf2);
        mStreamSlotCount = 1;
        mStreamSlotCount = 1;
    }
    }
    return signalConsumerLocked();
    return signalConsumerLocked();
@@ -322,11 +328,22 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(
{
{
    ALOGV("%s: E", __FUNCTION__);
    ALOGV("%s: E", __FUNCTION__);
    Mutex::Autolock l(mMutex);
    Mutex::Autolock l(mMutex);
    status_t res;

    if (mStreamSlotCount > 0) {
    if (mStreamSlotCount > 0) {
        freeBuffers(mStreamSlot.begin(), mStreamSlot.end());
        freeBuffers(mStreamSlot.begin(), mStreamSlot.end());
    }
    }
    mStreamSlot = bufs;
    mStreamSlotCount = 0;
    mStreamSlotCount = mStreamSlot.size();
    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);
        mStreamSlotCount++;
    }
    return signalConsumerLocked();
    return signalConsumerLocked();
}
}


+2 −1
Original line number Original line Diff line number Diff line
@@ -87,7 +87,8 @@ class Camera2Device : public virtual RefBase {


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