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

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

Camera3Device: Fix regression to old camera API operation.

When Camera2Client uses Camera3Device, it operates with lazy stream
configuration (in which streams are configured only once a capture
request is going to actually be sent). In this path, the operating
mode may never get set to a valid mode, and thus always fail
stream configuration.

Ensure that all paths calling into configureStreamsLocked set the
appropriate operating mode.

Test: Actually no camera CTS regressions this time, honest!
Bug: 34853980
Change-Id: I6e1855206f6d76cca5ff8348555b26bd7b868843
parent bbbbe84b
Loading
Loading
Loading
Loading
+24 −15
Original line number Diff line number Diff line
@@ -1104,7 +1104,9 @@ sp<Camera3Device::CaptureRequest> Camera3Device::setUpRequestLocked(
    status_t res;

    if (mStatus == STATUS_UNCONFIGURED || mNeedConfig) {
        res = configureStreamsLocked();
        // This point should only be reached via API1 (API2 must explicitly call configureStreams)
        // so unilaterally select normal operating mode.
        res = configureStreamsLocked(CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE);
        // Stream configuration failed. Client might try other configuraitons.
        if (res != OK) {
            CLOGE("Can't set up streams: %s (%d)", strerror(-res), res);
@@ -1206,7 +1208,8 @@ status_t Camera3Device::createInputStream(
    // Continue captures if active at start
    if (wasActive) {
        ALOGV("%s: Restarting activity to reconfigure streams", __FUNCTION__);
        res = configureStreamsLocked();
        // Reuse current operating mode for new stream config
        res = configureStreamsLocked(mOperatingMode);
        if (res != OK) {
            ALOGE("%s: Can't reconfigure device for new stream %d: %s (%d)",
                    __FUNCTION__, mNextStreamId, strerror(-res), res);
@@ -1368,7 +1371,8 @@ status_t Camera3Device::createStream(const std::vector<sp<Surface>>& consumers,
    // Continue captures if active at start
    if (wasActive) {
        ALOGV("%s: Restarting activity to reconfigure streams", __FUNCTION__);
        res = configureStreamsLocked();
        // Reuse current operating mode for new stream config
        res = configureStreamsLocked(mOperatingMode);
        if (res != OK) {
            CLOGE("Can't reconfigure device for new stream %d: %s (%d)",
                    mNextStreamId, strerror(-res), res);
@@ -1519,17 +1523,7 @@ status_t Camera3Device::configureStreams(int operatingMode) {
    Mutex::Autolock il(mInterfaceLock);
    Mutex::Autolock l(mLock);

    bool isConstrainedHighSpeed =
            static_cast<int>(StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE) ==
            operatingMode;

    if (mOperatingMode != operatingMode) {
        mNeedConfig = true;
        mIsConstrainedHighSpeedConfiguration = isConstrainedHighSpeed;
        mOperatingMode = operatingMode;
    }

    return configureStreamsLocked();
    return configureStreamsLocked(operatingMode);
}

status_t Camera3Device::getInputBufferProducer(
@@ -2177,7 +2171,7 @@ void Camera3Device::cancelStreamsConfigurationLocked() {
    mNeedConfig = true;
}

status_t Camera3Device::configureStreamsLocked() {
status_t Camera3Device::configureStreamsLocked(int operatingMode) {
    ATRACE_CALL();
    status_t res;

@@ -2186,6 +2180,21 @@ status_t Camera3Device::configureStreamsLocked() {
        return INVALID_OPERATION;
    }

    if (operatingMode < 0) {
        CLOGE("Invalid operating mode: %d", operatingMode);
        return BAD_VALUE;
    }

    bool isConstrainedHighSpeed =
            static_cast<int>(StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE) ==
            operatingMode;

    if (mOperatingMode != operatingMode) {
        mNeedConfig = true;
        mIsConstrainedHighSpeedConfiguration = isConstrainedHighSpeed;
        mOperatingMode = operatingMode;
    }

    if (!mNeedConfig) {
        ALOGV("%s: Skipping config, no stream changes", __FUNCTION__);
        return OK;
+1 −1
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ class Camera3Device :
     * Take the currently-defined set of streams and configure the HAL to use
     * them. This is a long-running operation (may be several hundered ms).
     */
    status_t           configureStreamsLocked();
    status_t           configureStreamsLocked(int operatingMode);

    /**
     * Cancel stream configuration that did not finish successfully.