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

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

Merge "Camera3: don't let dequeueBuffer block indefinitely" into nyc-mr1-dev

parents 2e1dfc8e f0645c19
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -3135,7 +3135,7 @@ bool Camera3Device::RequestThread::threadLoop() {
        mFlushLock.lock();
        mFlushLock.lock();
    }
    }


    ALOGVV("%s: %d: submitting %d requests in a batch.", __FUNCTION__, __LINE__,
    ALOGVV("%s: %d: submitting %zu requests in a batch.", __FUNCTION__, __LINE__,
            mNextRequests.size());
            mNextRequests.size());
    for (auto& nextRequest : mNextRequests) {
    for (auto& nextRequest : mNextRequests) {
        // Submit request and block until ready for next one
        // Submit request and block until ready for next one
+17 −0
Original line number Original line Diff line number Diff line
@@ -472,6 +472,12 @@ status_t Camera3OutputStream::configureQueueLocked() {
                __FUNCTION__, mTransform, strerror(-res), res);
                __FUNCTION__, mTransform, strerror(-res), res);
    }
    }


    // Set dequeueBuffer/attachBuffer timeout if the consumer is not hw composer or hw texture.
    // We need skip these cases as timeout will disable the non-blocking (async) mode.
    if (!(isConsumedByHWComposer() || isConsumedByHWTexture())) {
        mConsumer->setDequeueTimeout(kDequeueBufferTimeout);
    }

    /**
    /**
     * Camera3 Buffer manager is only supported by HAL3.3 onwards, as the older HALs requires
     * Camera3 Buffer manager is only supported by HAL3.3 onwards, as the older HALs requires
     * buffers to be statically allocated for internal static buffer registration, while the
     * buffers to be statically allocated for internal static buffer registration, while the
@@ -701,6 +707,17 @@ bool Camera3OutputStream::isConsumedByHWComposer() const {
    return (usage & GRALLOC_USAGE_HW_COMPOSER) != 0;
    return (usage & GRALLOC_USAGE_HW_COMPOSER) != 0;
}
}


bool Camera3OutputStream::isConsumedByHWTexture() const {
    uint32_t usage = 0;
    status_t res = getEndpointUsage(&usage);
    if (res != OK) {
        ALOGE("%s: getting end point usage failed: %s (%d).", __FUNCTION__, strerror(-res), res);
        return false;
    }

    return (usage & GRALLOC_USAGE_HW_TEXTURE) != 0;
}

}; // namespace camera3
}; // namespace camera3


}; // namespace android
}; // namespace android
+8 −0
Original line number Original line Diff line number Diff line
@@ -127,6 +127,11 @@ class Camera3OutputStream :
     */
     */
    bool isConsumedByHWComposer() const;
    bool isConsumedByHWComposer() const;


    /**
     * Return if this output stream is consumed by hardware texture.
     */
    bool isConsumedByHWTexture() const;

    /**
    /**
     * Return if the consumer configuration of this stream is deferred.
     * Return if the consumer configuration of this stream is deferred.
     */
     */
@@ -181,6 +186,9 @@ class Camera3OutputStream :
    sp<Surface> mConsumer;
    sp<Surface> mConsumer;


  private:
  private:

    static const nsecs_t       kDequeueBufferTimeout   = 1000000000; // 1 sec

    int               mTransform;
    int               mTransform;


    virtual status_t  setTransformLocked(int transform);
    virtual status_t  setTransformLocked(int transform);