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

Commit 768cf093 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

Camera2: Erase ZSL queue after each use.

Since preview stops after a capture is submitted, need to clear out
the ZSL queue to avoid using stale buffers when the preview starts up
again.

Bug: 7189765
Change-Id: I9ae2382d0af132208aca5ccba49b5464d18a263e
parent fe580e57
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -223,6 +223,11 @@ CaptureSequencer::CaptureState CaptureSequencer::manageDone(sp<Camera2Client> &c
                res = INVALID_OPERATION;
        }
    }
    sp<ZslProcessor> processor = mZslProcessor.promote();
    if (processor != 0) {
        processor->clearZslQueue();
    }

    if (mCaptureBuffer != 0 && res == OK) {
        Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
        ALOGV("%s: Sending still image to client", __FUNCTION__);
+24 −1
Original line number Diff line number Diff line
@@ -97,6 +97,10 @@ void ZslProcessor::onBufferReleased(buffer_handle_t *handle) {
                __FUNCTION__, handle);
    }

    // Erase entire ZSL queue since we've now completed the capture and preview
    // is stopped.
    clearZslQueueLocked();

    mState = RUNNING;
}

@@ -240,7 +244,6 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
        dumpZslQueue(-1);
    }


    if (mZslQueueTail != mZslQueueHead) {
        CameraMetadata request;
        size_t index = mZslQueueTail;
@@ -312,6 +315,26 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
    return OK;
}

status_t ZslProcessor::clearZslQueue() {
    Mutex::Autolock l(mInputMutex);
    // If in middle of capture, can't clear out queue
    if (mState == LOCKED) return OK;

    return clearZslQueueLocked();
}

status_t ZslProcessor::clearZslQueueLocked() {
    for (size_t i = 0; i < mZslQueue.size(); i++) {
        if (mZslQueue[i].buffer.mTimestamp != 0) {
            mZslConsumer->releaseBuffer(mZslQueue[i].buffer);
        }
        mZslQueue.replaceAt(i);
    }
    mZslQueueHead = 0;
    mZslQueueTail = 0;
    return OK;
}

void ZslProcessor::dump(int fd, const Vector<String16>& args) const {
    Mutex::Autolock l(mInputMutex);
    dumpZslQueue(fd);
+3 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ class ZslProcessor:
    int getReprocessStreamId() const;

    status_t pushToReprocess(int32_t requestId);
    status_t clearZslQueue();

    void dump(int fd, const Vector<String16>& args) const;
  private:
@@ -111,6 +112,8 @@ class ZslProcessor:
    // Match up entries from frame list to buffers in ZSL queue
    void findMatchesLocked();

    status_t clearZslQueueLocked();

    void dumpZslQueue(int id) const;
};