Camera: Make finalizeOutputConfigurations more resilient
There could be race in application where finalizeOutputconfigurations
doesn't include any new surface. Do not fail in this case.
Test: CameraStressTest#testBackCameraSwitchPreview
Bug: 36811459
Bug: 35137641
Change-Id: Ic185e6d8bfcb8af5b81a33fbbd2fd4e49cc647ce
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index a77a90b7..f2e8df8 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -1269,6 +1269,13 @@
surfaceId++;
}
+ // Gracefully handle case where finalizeOutputConfigurations is called
+ // without any new surface.
+ if (consumerSurfaces.size() == 0) {
+ mStreamInfoMap[streamId].finalized = true;
+ return res;
+ }
+
// Finish the deferred stream configuration with the surface.
status_t err;
err = mDevice->setConsumerSurfaces(streamId, consumerSurfaces);