From: Igor Murashkin Date: Mon, 8 Oct 2012 22:09:46 +0000 (-0700) Subject: Camera2: Always disconnect in the client destructor X-Git-Tag: android-x86-4.4-r1~23^2~80^2~11^2~48^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=be8d28a12e8d08531c6053bcf8ad1183c2f6e6d3;p=android-x86%2Fframeworks-av.git Camera2: Always disconnect in the client destructor If Camera2Client failed to initialize, it would skip disconnect step, and thus the camera would be forever marked as busy. By always calling disconnect it will always call free. It also adds a new guarantee that Client::disconnect is idempotent Bug: 7298182 Change-Id: Ic9876f1665b7d9b3c0da692880f63f165e3f4fa5 --- diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 6fbd6edb6a..124d24d4b4 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -409,6 +409,9 @@ CameraService::Client::Client(const sp& cameraService, // tear down the client CameraService::Client::~Client() { mCameraService->releaseSound(); + + // unconditionally disconnect. function is idempotent + Client::disconnect(); } // ---------------------------------------------------------------------------- @@ -433,6 +436,7 @@ CameraService::Client* CameraService::Client::getClientFromCookie(void* user) { return client; } +// NOTE: function is idempotent void CameraService::Client::disconnect() { mCameraService->removeClient(mCameraClient); mCameraService->setCameraFree(mCameraId);