Fix a deadlock in commandSetVideoBufferCountL()
o The lock to be acquired in recordingEnabled() has aleady been acquired in sendCommand()
before the call to commandSetVideoBufferCountL().
Change-Id: I664d51ef449c9eb3576d5d56f73f29c98444ff3f
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index dfcc8c0..cd74e6d 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -792,8 +792,15 @@
bool Camera2Client::recordingEnabled() {
ATRACE_CALL();
Mutex::Autolock icl(mICameraLock);
+
if ( checkPid(__FUNCTION__) != OK) return false;
+ return recordingEnabledL();
+}
+
+bool Camera2Client::recordingEnabledL() {
+ ATRACE_CALL();
+
return (mState == RECORD || mState == VIDEO_SNAPSHOT);
}
@@ -1632,7 +1639,7 @@
}
status_t Camera2Client::commandSetVideoBufferCountL(size_t count) {
- if (recordingEnabled()) {
+ if (recordingEnabledL()) {
ALOGE("%s: Camera %d: Error setting video buffer count after "
"recording was started", __FUNCTION__, mCameraId);
return INVALID_OPERATION;
diff --git a/services/camera/libcameraservice/Camera2Client.h b/services/camera/libcameraservice/Camera2Client.h
index 2e6a36c..8c10d6b 100644
--- a/services/camera/libcameraservice/Camera2Client.h
+++ b/services/camera/libcameraservice/Camera2Client.h
@@ -108,6 +108,8 @@
void stopPreviewL();
status_t startPreviewL();
+ bool recordingEnabledL();
+
// Individual commands for sendCommand()
status_t commandStartSmoothZoomL();
status_t commandStopSmoothZoomL();