summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChien-Yu Chen <cychen@google.com>2018-04-11 15:29:46 -0700
committerChien-Yu Chen <cychen@google.com>2018-04-12 17:03:46 -0700
commitf8887c0115eeb72871ab71caa16e23334717a7f5 (patch)
tree551568b50de0b47d0c8e5a918ce2f6f7f2a8fbfd
parent206360b89e5455feb0b1084e7c79eb4d72b2c281 (diff)
downloadcamera-f8887c0115eeb72871ab71caa16e23334717a7f5.tar.gz
Qcamera2: Clean up Easel error future
Clean up Easel error future in the beginning of QCamera3HWI destructor to avoid Easel error reporting in the middle of the destructor. Test: GCA, Camera CTS Bug: 73635044 Change-Id: Iab21a71e81a99075e10ca9c0ea45606712ca3200
-rw-r--r--msm8998/QCamera2/HAL3/QCamera3HWI.cpp18
-rw-r--r--msm8998/QCamera2/HAL3/QCamera3HWI.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/msm8998/QCamera2/HAL3/QCamera3HWI.cpp b/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
index d0ad8d0..73f2094 100644
--- a/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
@@ -638,6 +638,9 @@ QCamera3HardwareInterface::~QCamera3HardwareInterface()
int32_t rc = 0;
+ // Clean up Easel error future first to avoid Easel error happens during destructor.
+ cleanupEaselErrorFuture();
+
// Disable power hint and enable the perf lock for close camera
mPerfLockMgr.releasePerfLock(PERF_LOCK_POWERHINT_ENCODE);
mPerfLockMgr.acquirePerfLock(PERF_LOCK_CLOSE_CAMERA);
@@ -15610,8 +15613,23 @@ void QCamera3HardwareInterface::handleEaselFatalError()
handleCameraDeviceError(/*stopChannelImmediately*/true);
}
+void QCamera3HardwareInterface::cleanupEaselErrorFuture()
+{
+ {
+ std::lock_guard<std::mutex> lock(mEaselErrorFutureLock);
+ if (!mEaselErrorFuture.valid()) {
+ // If there is no Easel error, construct a dummy future to wait for.
+ mEaselErrorFuture = std::async([]() { return; });
+ }
+ }
+
+ mEaselErrorFuture.wait();
+}
+
void QCamera3HardwareInterface::handleEaselFatalErrorAsync()
{
+ std::lock_guard<std::mutex> lock(mEaselErrorFutureLock);
+
if (mEaselErrorFuture.valid()) {
// The error future has been invoked.
return;
diff --git a/msm8998/QCamera2/HAL3/QCamera3HWI.h b/msm8998/QCamera2/HAL3/QCamera3HWI.h
index 13f3c0e..20abff8 100644
--- a/msm8998/QCamera2/HAL3/QCamera3HWI.h
+++ b/msm8998/QCamera2/HAL3/QCamera3HWI.h
@@ -857,6 +857,9 @@ private:
// Easel manager client callbacks.
void onEaselFatalError(std::string errMsg);
+ // Clean up and wait for Easel error future.
+ void cleanupEaselErrorFuture();
+
// HDR+ client callbacks.
void onOpened(std::unique_ptr<HdrPlusClient> client) override;
void onOpenFailed(status_t err) override;
@@ -900,6 +903,7 @@ private:
int32_t mSceneDistance;
+ std::mutex mEaselErrorFutureLock;
std::future<void> mEaselErrorFuture;
// Thread to handle callbacks from HDR+ client. Protected by gHdrPlusClientLock.