[libcamera-devel] [PATCH] android: mm: cros_camera_buffer: Log failure error on cleanup

Umang Jain umang.jain at ideasonboard.com
Tue Sep 7 16:54:59 CEST 2021


Failure can still happen by CameraBufferManager during Unlock() and/or
Deregister() of camera3Buffer handles. We should be logging those
errors as well.

Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
---
I have been able to spot one of the failure which is happening on my
in-developement async post-processing. It is due a failure in
Deregister(). It is intermittent and non-fatal as far as I can see.

Having a failure log in HAL, apart from https://paste.debian.net/1210728/
helps to know the exact place from where the error is originating from
libcamera HAL.
---
 src/android/mm/cros_camera_buffer.cpp | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/android/mm/cros_camera_buffer.cpp b/src/android/mm/cros_camera_buffer.cpp
index ec45e04c..307914c3 100644
--- a/src/android/mm/cros_camera_buffer.cpp
+++ b/src/android/mm/cros_camera_buffer.cpp
@@ -73,10 +73,20 @@ CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer,
 
 CameraBuffer::Private::~Private()
 {
-	if (mapped_)
-		bufferManager_->Unlock(handle_);
-	if (registered_)
-		bufferManager_->Deregister(handle_);
+	int ret;
+	if (mapped_) {
+		ret = bufferManager_->Unlock(handle_);
+		if (ret != 0)
+			LOG(HAL, Error) << "Failed to unlock buffer: "
+					<< strerror(-ret);
+	}
+
+	if (registered_) {
+		ret = bufferManager_->Deregister(handle_);
+		if (ret != 0)
+			LOG(HAL, Error) << "Failed to deregister buffer: "
+					<< strerror(-ret);
+	}
 }
 
 unsigned int CameraBuffer::Private::numPlanes() const
@@ -138,6 +148,7 @@ size_t CameraBuffer::Private::jpegBufferSize([[maybe_unused]] size_t maxJpegBuff
 void CameraBuffer::Private::map()
 {
 	int ret;
+	LOG(HAL, Error) << "GEtting mapped : " << numPlanes_;
 	switch (numPlanes_) {
 	case 1: {
 		ret = bufferManager_->Lock(handle_, 0, 0, 0, 0, 0, &mem.addr);
-- 
2.31.0



More information about the libcamera-devel mailing list