From 5e4c732e8646ec700b495bc9ca532d92034f44fb Mon Sep 17 00:00:00 2001 From: Emilian Peev Date: Tue, 22 Oct 2019 14:20:52 -0700 Subject: [PATCH] Camera: Release all composite streams during "detachDevice" "CameraDeviceClient" which keeps all references to active composite streams may not get immediately destroyed after client disconnect. This means that all registered output surfaces in composite streams will continue to have an active connection. In such scenario camera clients will not be able to re-use the same surface as long as the older instances are still alive. Avoid this behavior by explicitly releasing all remaining composite streams during "detachDevice". The method must be called as part of the client disconnect and will ensure that all surface connections are removed. Bug: 143212133 Test: Camera CTS Change-Id: I08710645539b687f046116a88576f05bbcbdbaff --- .../camera/libcameraservice/api2/CameraDeviceClient.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp index c7a4f2bfad..3587db33d9 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp @@ -2004,6 +2004,15 @@ void CameraDeviceClient::detachDevice() { } } + for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { + auto ret = mCompositeStreamMap.valueAt(i)->deleteInternalStreams(); + if (ret != OK) { + ALOGE("%s: Failed removing composite stream %s (%d)", __FUNCTION__, + strerror(-ret), ret); + } + } + mCompositeStreamMap.clear(); + Camera2ClientBase::detachDevice(); }