summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2012-10-08 15:09:46 -0700
committerIgor Murashkin <iam@google.com>2012-10-08 15:09:46 -0700
commit036bc3e2cfc5a11c3f7ace41088c8936dae2e946 (patch)
tree1be259dbec33d2e33afe1104bb929cd0e37c18b2
parent6f854608d26d7abcce5e46396c7260ed7b250653 (diff)
downloadframeworks_av-036bc3e2cfc5a11c3f7ace41088c8936dae2e946.zip
frameworks_av-036bc3e2cfc5a11c3f7ace41088c8936dae2e946.tar.gz
frameworks_av-036bc3e2cfc5a11c3f7ace41088c8936dae2e946.tar.bz2
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
-rw-r--r--services/camera/libcameraservice/CameraService.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 6fbd6ed..124d24d 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -409,6 +409,9 @@ CameraService::Client::Client(const sp<CameraService>& 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);