summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2010-09-05 13:42:38 +0000
committerGerrit Code Review <gerrit2@cyanogenmod.teamdouche.net>2010-09-05 13:42:38 +0000
commit03965c4579ddb9c62c30bdd393da47dbcfbdc9ca (patch)
tree804eee9a673b5bdf81001c8ce8e3e1ceb5120f9d
parentc98bddaf249866c59acd4fde3620e1ff4e66e619 (diff)
parente3a089d5eb5c60676241523008250a8494d47e57 (diff)
downloadframeworks_base-03965c4579ddb9c62c30bdd393da47dbcfbdc9ca.zip
frameworks_base-03965c4579ddb9c62c30bdd393da47dbcfbdc9ca.tar.gz
frameworks_base-03965c4579ddb9c62c30bdd393da47dbcfbdc9ca.tar.bz2
Merge "Camera : Clean up old camera client properly" into froyo
-rwxr-xr-x[-rw-r--r--]camera/libcameraservice/CameraService.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 0ac089f..3cb3ce5 100644..100755
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -81,6 +81,8 @@ static int getCallingPid() {
return IPCThreadState::self()->getCallingPid();
}
+static bool cleanOldclient = false;
+
// ----------------------------------------------------------------------------
void CameraService::instantiate() {
@@ -129,8 +131,14 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
currentClient->mClientPid, currentCameraClient->asBinder().get());
if (kill(currentClient->mClientPid, 0) == -1 && errno == ESRCH) {
LOGV("The old client is dead!");
+ LOGE("forcefully terminating old client.. ref count ", currentClient->getStrongCount());
+ cleanOldclient = true;
+ mServiceLock.unlock();
+
+ currentClient->disconnect();
+ cleanOldclient = false;
}
- return client;
+ else return client;
}
} else {
// can't promote, the previous client has died...
@@ -144,7 +152,7 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
LOGV("Still have client, rejected");
return client;
}
-
+ LOGV("creating new client");
// create a new Client object
client = new Client(this, cameraClient, callingPid);
mClient = client;
@@ -396,12 +404,14 @@ void CameraService::Client::disconnect()
LOGV("Client::disconnect() E (pid %d client %p)",
callingPid, getCameraClient()->asBinder().get());
- Mutex::Autolock lock(mLock);
+ if(!cleanOldclient)
+ Mutex::Autolock lock(mLock);
+
if (mClientPid <= 0) {
LOGV("camera is unlocked (mClientPid = %d), don't tear down hardware", mClientPid);
return;
}
- if (checkPid() != NO_ERROR) {
+ if (!cleanOldclient && checkPid() != NO_ERROR) {
LOGV("Different client - don't disconnect");
return;
}