[v14,2/7] libcamera: Remove PipelineHandler Fatal check of non-empty MediaDevices
diff mbox series

Message ID 20240930063342.3014837-3-chenghaoyang@google.com
State New
Headers show
Series
  • Add VirtualPipelineHandler
Related show

Commit Message

Harvey Yang Sept. 30, 2024, 6:29 a.m. UTC
The Fatal check of having at least one MediaDevice was to prevent
pipeline handler implementations searching and owning media devices with
custom conventions, instead of using the base function
|acquireMediaDevice|. It also has the assumption that there's at least
one media device to make a camera work.

Now that the assumption will be broken by the virtual pipeline handler
added in the following patches, and developers should be aware of the
available functions in the base class to handle media devices, the Fatal
check is no longer needed.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline_handler.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Kieran Bingham Oct. 3, 2024, 8:23 a.m. UTC | #1
Quoting Harvey Yang (2024-09-30 07:29:43)
> The Fatal check of having at least one MediaDevice was to prevent
> pipeline handler implementations searching and owning media devices with
> custom conventions, instead of using the base function
> |acquireMediaDevice|. It also has the assumption that there's at least
> one media device to make a camera work.
> 
> Now that the assumption will be broken by the virtual pipeline handler
> added in the following patches, and developers should be aware of the
> available functions in the base class to handle media devices, the Fatal
> check is no longer needed.
> 
> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/pipeline_handler.cpp | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> index e5940469..89a513e4 100644
> --- a/src/libcamera/pipeline_handler.cpp
> +++ b/src/libcamera/pipeline_handler.cpp
> @@ -637,9 +637,14 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)
>  {
>         cameras_.push_back(camera);
>  
> -       if (mediaDevices_.empty())
> -               LOG(Pipeline, Fatal)
> -                       << "Registering camera with no media devices!";
> +       if (mediaDevices_.empty()) {
> +               /*
> +                * For virtual devices with no MediaDevice, there are no system
> +                * devices to register.
> +                */
> +               manager_->_d()->addCamera(std::move(camera));
> +               return;
> +       }


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

>  
>         /*
>          * Walk the entity list and map the devnums of all capture video nodes
> -- 
> 2.46.1.824.gd892dcdcdd-goog
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index e5940469..89a513e4 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -637,9 +637,14 @@  void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)
 {
 	cameras_.push_back(camera);
 
-	if (mediaDevices_.empty())
-		LOG(Pipeline, Fatal)
-			<< "Registering camera with no media devices!";
+	if (mediaDevices_.empty()) {
+		/*
+		 * For virtual devices with no MediaDevice, there are no system
+		 * devices to register.
+		 */
+		manager_->_d()->addCamera(std::move(camera));
+		return;
+	}
 
 	/*
 	 * Walk the entity list and map the devnums of all capture video nodes