summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2013-06-13 12:20:02 -0700
committerEino-Ville Talvala <etalvala@google.com>2013-06-13 12:20:02 -0700
commit214a17fd37ef85fc841d3157b1e9096e1aa1b42f (patch)
treebb2b77358dd771303a15f320388e4d68104ebb58 /services
parent1191454a3a960a1972b0f36e625796c6c1b2c9ca (diff)
downloadframeworks_av-214a17fd37ef85fc841d3157b1e9096e1aa1b42f.zip
frameworks_av-214a17fd37ef85fc841d3157b1e9096e1aa1b42f.tar.gz
frameworks_av-214a17fd37ef85fc841d3157b1e9096e1aa1b42f.tar.bz2
Camera3: Always close HAL device even in face of errors.
To improve robustness, make sure the HAL device instance is always closed, even if it cannot be put into the IDLE state. Bug: 9414167 Change-Id: I8e7035ff0afe7214951f9824e561b340cb37592e
Diffstat (limited to 'services')
-rw-r--r--services/camera/libcameraservice/Camera3Device.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/services/camera/libcameraservice/Camera3Device.cpp b/services/camera/libcameraservice/Camera3Device.cpp
index 6ee6901..cc7802b 100644
--- a/services/camera/libcameraservice/Camera3Device.cpp
+++ b/services/camera/libcameraservice/Camera3Device.cpp
@@ -181,24 +181,29 @@ status_t Camera3Device::disconnect() {
ALOGV("%s: E", __FUNCTION__);
- status_t res;
- if (mStatus == STATUS_UNINITIALIZED) return OK;
+ status_t res = OK;
+ if (mStatus == STATUS_UNINITIALIZED) return res;
if (mStatus == STATUS_ACTIVE ||
(mStatus == STATUS_ERROR && mRequestThread != NULL)) {
res = mRequestThread->clearRepeatingRequests();
if (res != OK) {
SET_ERR_L("Can't stop streaming");
- return res;
- }
- res = waitUntilDrainedLocked();
- if (res != OK) {
- SET_ERR_L("Timeout waiting for HAL to drain");
- return res;
+ // Continue to close device even in case of error
+ } else {
+ res = waitUntilDrainedLocked();
+ if (res != OK) {
+ SET_ERR_L("Timeout waiting for HAL to drain");
+ // Continue to close device even in case of error
+ }
}
}
assert(mStatus == STATUS_IDLE || mStatus == STATUS_ERROR);
+ if (mStatus == STATUS_ERROR) {
+ CLOGE("Shutting down in an error state");
+ }
+
if (mRequestThread != NULL) {
mRequestThread->requestExit();
}
@@ -207,7 +212,12 @@ status_t Camera3Device::disconnect() {
mInputStream.clear();
if (mRequestThread != NULL) {
- mRequestThread->join();
+ if (mStatus != STATUS_ERROR) {
+ // HAL may be in a bad state, so waiting for request thread
+ // (which may be stuck in the HAL processCaptureRequest call)
+ // could be dangerous.
+ mRequestThread->join();
+ }
mRequestThread.clear();
}
@@ -219,7 +229,7 @@ status_t Camera3Device::disconnect() {
mStatus = STATUS_UNINITIALIZED;
ALOGV("%s: X", __FUNCTION__);
- return OK;
+ return res;
}
status_t Camera3Device::dump(int fd, const Vector<String16> &args) {