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

Commit 88fd0050 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera: Allow finalizeOutputConfiguration not adding new surface

If the application calls finalizeOutputConfiguration without adding new
surface, as long as there is at least one surface in the
OutputConfiguration, do not throw exception.

Add logic to not allow finalizeOutputConfigurations twice on a
particular stream.

Test: testDeferredSurfaces cts and GoogleCameraApp manual test.
Bug: 35137641
Change-Id: I96061231e9b884e73c92520e7f2c021db32fa731
parent f5f40560
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -1217,6 +1217,13 @@ binder::Status CameraDeviceClient::finalizeOutputConfigurations(int32_t streamId
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
    }

    if (mStreamInfoMap[streamId].finalized) {
        String8 msg = String8::format("Camera %s: finalizeOutputConfigurations has been called"
                " on stream ID %d", mCameraIdStr.string(), streamId);
        ALOGW("%s: %s", __FUNCTION__, msg.string());
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
    }

    if (!mDevice.get()) {
        return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
    }
@@ -1246,13 +1253,6 @@ binder::Status CameraDeviceClient::finalizeOutputConfigurations(int32_t streamId
        surfaceId++;
    }

    if (consumerSurfaces.size() == 0) {
        String8 msg = String8::format("Camera %s: New OutputConfiguration has the same surfaces"
                " for stream (ID %d)", mCameraIdStr.string(), streamId);
        ALOGW("%s: %s", __FUNCTION__, msg.string());
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
    }

    // Finish the deferred stream configuration with the surface.
    status_t err;
    err = mDevice->setConsumerSurfaces(streamId, consumerSurfaces);
@@ -1267,6 +1267,7 @@ binder::Status CameraDeviceClient::finalizeOutputConfigurations(int32_t streamId
        if (deferredStreamIndex != NAME_NOT_FOUND) {
            mDeferredStreams.removeItemsAt(deferredStreamIndex);
        }
        mStreamInfoMap[streamId].finalized = true;
    } else if (err == NO_INIT) {
        res = STATUS_ERROR_FMT(CameraService::ERROR_ILLEGAL_ARGUMENT,
                "Camera %s: Deferred surface is invalid: %s (%d)",
+1 −0
Original line number Diff line number Diff line
@@ -215,6 +215,7 @@ private:
        int format;
        android_dataspace dataSpace;
        int32_t consumerUsage;
        bool finalized = false;
        OutputStreamInfo() :
                width(-1), height(-1), format(-1), dataSpace(HAL_DATASPACE_UNKNOWN),
                consumerUsage(0) {}