[RFC,v1,51/54] android: camera_device: Move fence restoration into `prepareToReturn()`
diff mbox series

Message ID 20260629163017.863145-52-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • libcamera: Split requests and buffers
Related show

Commit Message

Barnabás Pőcze June 29, 2026, 4:30 p.m. UTC
It is sufficient to restore the fence for returning it to the camera framework
just before the returned `camera3_stream_buffer_t` is constructed, so do that.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/android/camera_device.cpp  | 19 +------------------
 src/android/camera_request.cpp | 13 +++++++++++++
 2 files changed, 14 insertions(+), 18 deletions(-)

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 0d5b5b97eb..09aa129e0a 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1146,25 +1146,8 @@  void CameraDevice::requestComplete(Request *request)
 	 * The buffer status is set to Success and later changed to Error if
 	 * post-processing/compression fails.
 	 */
-	for (auto &buffer : descriptor->buffers_) {
-		CameraStream *stream = buffer.stream;
-
-		/*
-		 * Streams of type Direct have been queued to the
-		 * libcamera::Camera and their acquire fences have
-		 * already been waited on by the library.
-		 *
-		 * Acquire fences of streams of type Internal and Mapped
-		 * will be handled during post-processing.
-		 */
-		if (stream->type() == CameraStream::Type::Direct) {
-			/* If handling of the fence has failed restore buffer.fence. */
-			std::unique_ptr<Fence> fence = buffer.frameBuffer->releaseFence();
-			if (fence)
-				buffer.fence = fence->release();
-		}
+	for (auto &buffer : descriptor->buffers_)
 		buffer.status = Camera3RequestDescriptor::Status::Success;
-	}
 
 	/*
 	 * If the Request has failed, abort the request by notifying the error
diff --git a/src/android/camera_request.cpp b/src/android/camera_request.cpp
index feac7a3e19..6dfe692f09 100644
--- a/src/android/camera_request.cpp
+++ b/src/android/camera_request.cpp
@@ -10,6 +10,7 @@ 
 #include <libcamera/base/span.h>
 
 #include "camera_buffer.h"
+#include "camera_stream.h"
 
 using namespace libcamera;
 
@@ -195,6 +196,18 @@  Camera3RequestDescriptor::StreamBuffer::operator=(Camera3RequestDescriptor::Stre
 
 camera3_stream_buffer_t Camera3RequestDescriptor::StreamBuffer::prepareToReturn()
 {
+	/*
+	 * Streams of type Direct have a non-nullptr `frameBuffer` and
+	 * have been queued to the libcamera::Camera and their acquire
+	 * fences have already been waited on by the library.
+	 */
+	if (frameBuffer) {
+		/* If handling of the fence has failed restore buffer.fence. */
+		auto f = frameBuffer->releaseFence();
+		if (f)
+			fence = f->release();
+	}
+
 	/*
 	 * Pass the buffer fence back to the camera framework as
 	 * a release fence. This instructs the framework to wait