[v1] libcamera: camera: Do not call `generateConfiguration()` synchronously
diff mbox series

Message ID 20250721120126.1563367-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1] libcamera: camera: Do not call `generateConfiguration()` synchronously
Related show

Commit Message

Barnabás Pőcze July 21, 2025, 12:01 p.m. UTC
Most pipeline handler methods are dispatched in the internal `CameraManager`
thread. `PipelineHandler::generateConfiguration()` was called directly,
however, which likely goes against the expectations, so call it on the
internal thread.

This could not be done before 14618cdd0c80a4 ("libcamera: base: bound_method: Move return value")
because the function returns `std::unique_ptr`, and that type cannot
be copied.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/libcamera/camera.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kieran Bingham July 21, 2025, 12:58 p.m. UTC | #1
Quoting Barnabás Pőcze (2025-07-21 13:01:26)
> Most pipeline handler methods are dispatched in the internal `CameraManager`
> thread. `PipelineHandler::generateConfiguration()` was called directly,
> however, which likely goes against the expectations, so call it on the
> internal thread.
> 
> This could not be done before 14618cdd0c80a4 ("libcamera: base: bound_method: Move return value")
> because the function returns `std::unique_ptr`, and that type cannot
> be copied.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/libcamera/camera.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 5efeadd53..423c5f3aa 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -1206,7 +1206,8 @@ std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(Span<const St
>                 return nullptr;
>  
>         std::unique_ptr<CameraConfiguration> config =
> -               d->pipe_->generateConfiguration(this, roles);
> +               d->pipe_->invokeMethod(&PipelineHandler::generateConfiguration,
> +                                      ConnectionTypeBlocking, this, roles);

Interesting. I hope this doesn't have any (negative) impact on the
currect testing of
https://github.com/raspberrypi/rpicam-apps/issues/799.

I think this is correct to make sure we're consistent calling things on
the pipeline handler in the internal threads though so:


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>         if (!config) {
>                 LOG(Camera, Debug)
>                         << "Pipeline handler failed to generate configuration";
> -- 
> 2.50.1
>

Patch
diff mbox series

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 5efeadd53..423c5f3aa 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -1206,7 +1206,8 @@  std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(Span<const St
 		return nullptr;
 
 	std::unique_ptr<CameraConfiguration> config =
-		d->pipe_->generateConfiguration(this, roles);
+		d->pipe_->invokeMethod(&PipelineHandler::generateConfiguration,
+				       ConnectionTypeBlocking, this, roles);
 	if (!config) {
 		LOG(Camera, Debug)
 			<< "Pipeline handler failed to generate configuration";