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

Commit ba435258 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Yin-Chia Yeh
Browse files

Camera: Device 3: Ignore buffer limits when clearing request queue

When abortCaptures is called, the request queue is cleared; as part of that,
any requests with input buffers trigger the removal and return of one input
buffer from the input stream.

However, if the HAL currently is processing some number of reprocess
requests, the stream's max buffer limit may have been reached, in
which case getInputBuffer will block until the HAL returns an input
buffer.  This stalls flushing (and calling of capture_request) for
some time, and seems to cause problems for the HAL during the flush.

So instead, don't respect the HAL's max buffer limit when all we're
doing is throwing work away.

Test: CTS, manual testing
Bug: 62420820
Change-Id: I72d8cdaf67fb3cc6876a03cee9e0021d95cecdfe
parent 38dfde5f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3598,7 +3598,8 @@ status_t Camera3Device::RequestThread::clear(
            // Abort the input buffers for reprocess requests.
            if ((*it)->mInputStream != NULL) {
                camera3_stream_buffer_t inputBuffer;
                status_t res = (*it)->mInputStream->getInputBuffer(&inputBuffer);
                status_t res = (*it)->mInputStream->getInputBuffer(&inputBuffer,
                        /*respectHalLimit*/ false);
                if (res != OK) {
                    ALOGW("%s: %d: couldn't get input buffer while clearing the request "
                            "list: %s (%d)", __FUNCTION__, __LINE__, strerror(-res), res);
+2 −2
Original line number Diff line number Diff line
@@ -544,7 +544,7 @@ status_t Camera3Stream::returnBuffer(const camera3_stream_buffer &buffer,
    return res;
}

status_t Camera3Stream::getInputBuffer(camera3_stream_buffer *buffer) {
status_t Camera3Stream::getInputBuffer(camera3_stream_buffer *buffer, bool respectHalLimit) {
    ATRACE_CALL();
    Mutex::Autolock l(mLock);
    status_t res = OK;
@@ -557,7 +557,7 @@ status_t Camera3Stream::getInputBuffer(camera3_stream_buffer *buffer) {
    }

    // Wait for new buffer returned back if we are running into the limit.
    if (getHandoutInputBufferCountLocked() == camera3_stream::max_buffers) {
    if (getHandoutInputBufferCountLocked() == camera3_stream::max_buffers && respectHalLimit) {
        ALOGV("%s: Already dequeued max input buffers (%d), wait for next returned one.",
                __FUNCTION__, camera3_stream::max_buffers);
        res = mInputBufferReturnedSignal.waitRelative(mLock, kWaitForBufferDuration);
+3 −1
Original line number Diff line number Diff line
@@ -308,8 +308,10 @@ class Camera3Stream :
     * For bidirectional streams, this method applies to the input-side
     * buffers.
     *
     * Normally this call will block until the handed out buffer count is less than the stream
     * max buffer count; if respectHalLimit is set to false, this is ignored.
     */
    status_t         getInputBuffer(camera3_stream_buffer *buffer);
    status_t         getInputBuffer(camera3_stream_buffer *buffer, bool respectHalLimit = true);

    /**
     * Return a buffer to the stream after use by the HAL.
+3 −1
Original line number Diff line number Diff line
@@ -232,8 +232,10 @@ class Camera3StreamInterface : public virtual RefBase {
     * For bidirectional streams, this method applies to the input-side
     * buffers.
     *
     * Normally this call will block until the handed out buffer count is less than the stream
     * max buffer count; if respectHalLimit is set to false, this is ignored.
     */
    virtual status_t getInputBuffer(camera3_stream_buffer *buffer) = 0;
    virtual status_t getInputBuffer(camera3_stream_buffer *buffer, bool respectHalLimit = true) = 0;

    /**
     * Return a buffer to the stream after use by the HAL.