[libcamera-devel,v2] libcamera: pipeline: uvcvideo: add warning if no default video device is found

Message ID 20190128005118.27099-1-niklas.soderlund@ragnatech.se
State Accepted
Commit 5745bd3df519ed3064b2e8d308b90834272504b8
Headers show
Series
  • [libcamera-devel,v2] libcamera: pipeline: uvcvideo: add warning if no default video device is found
Related show

Commit Message

Niklas Söderlund Jan. 28, 2019, 12:51 a.m. UTC
If for any reason a default video device is not found in the media graph
the creation of the UVC pipeline silently failed. This is not optimal
when debugging problems with the pipeline, add an error to notify the
user of the issue.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/pipeline/uvcvideo.cpp | 6 ++++++
 1 file changed, 6 insertions(+)
---
* Changes since v1
- Make the log output an Error instead of a Warning

Comments

Laurent Pinchart Jan. 30, 2019, 9:49 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Mon, Jan 28, 2019 at 01:51:18AM +0100, Niklas Söderlund wrote:
> If for any reason a default video device is not found in the media graph
> the creation of the UVC pipeline silently failed. This is not optimal
> when debugging problems with the pipeline, add an error to notify the
> user of the issue.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/pipeline/uvcvideo.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> ---
> * Changes since v1
> - Make the log output an Error instead of a Warning
> 
> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
> index c51e8bc1f2c2bf25..2ebdb2b9eb880174 100644
> --- a/src/libcamera/pipeline/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo.cpp
> @@ -8,12 +8,15 @@
>  #include <libcamera/camera.h>
>  
>  #include "device_enumerator.h"
> +#include "log.h"
>  #include "media_device.h"
>  #include "pipeline_handler.h"
>  #include "v4l2_device.h"
>  
>  namespace libcamera {
>  
> +LOG_DEFINE_CATEGORY(UVC)
> +
>  class PipelineHandlerUVC : public PipelineHandler
>  {
>  public:
> @@ -60,6 +63,9 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
>  	}
>  
>  	if (!video_ || video_->open()) {
> +		if (!video_)
> +			LOG(UVC, Error) << "Could not find a default video device";
> +
>  		media_->release();
>  		return false;
>  	}
Kieran Bingham Jan. 30, 2019, 9:52 a.m. UTC | #2
Hi Niklas,

With s/warning/error/ in the commit title:

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


On 28/01/2019 00:51, Niklas Söderlund wrote:
> If for any reason a default video device is not found in the media graph
> the creation of the UVC pipeline silently failed. This is not optimal
> when debugging problems with the pipeline, add an error to notify the
> user of the issue.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/libcamera/pipeline/uvcvideo.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> ---
> * Changes since v1
> - Make the log output an Error instead of a Warning
> 
> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
> index c51e8bc1f2c2bf25..2ebdb2b9eb880174 100644
> --- a/src/libcamera/pipeline/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo.cpp
> @@ -8,12 +8,15 @@
>  #include <libcamera/camera.h>
>  
>  #include "device_enumerator.h"
> +#include "log.h"
>  #include "media_device.h"
>  #include "pipeline_handler.h"
>  #include "v4l2_device.h"
>  
>  namespace libcamera {
>  
> +LOG_DEFINE_CATEGORY(UVC)
> +
>  class PipelineHandlerUVC : public PipelineHandler
>  {
>  public:
> @@ -60,6 +63,9 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
>  	}
>  
>  	if (!video_ || video_->open()) {
> +		if (!video_)
> +			LOG(UVC, Error) << "Could not find a default video device";
> +
>  		media_->release();
>  		return false;
>  	}
>
Niklas Söderlund Jan. 30, 2019, 12:02 p.m. UTC | #3
Hi,

On 2019-01-30 09:52:38 +0000, Kieran Bingham wrote:
> Hi Niklas,
> 
> With s/warning/error/ in the commit title:

With this fix pushed to master.

> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> 
> On 28/01/2019 00:51, Niklas Söderlund wrote:
> > If for any reason a default video device is not found in the media graph
> > the creation of the UVC pipeline silently failed. This is not optimal
> > when debugging problems with the pipeline, add an error to notify the
> > user of the issue.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  src/libcamera/pipeline/uvcvideo.cpp | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > ---
> > * Changes since v1
> > - Make the log output an Error instead of a Warning
> > 
> > diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
> > index c51e8bc1f2c2bf25..2ebdb2b9eb880174 100644
> > --- a/src/libcamera/pipeline/uvcvideo.cpp
> > +++ b/src/libcamera/pipeline/uvcvideo.cpp
> > @@ -8,12 +8,15 @@
> >  #include <libcamera/camera.h>
> >  
> >  #include "device_enumerator.h"
> > +#include "log.h"
> >  #include "media_device.h"
> >  #include "pipeline_handler.h"
> >  #include "v4l2_device.h"
> >  
> >  namespace libcamera {
> >  
> > +LOG_DEFINE_CATEGORY(UVC)
> > +
> >  class PipelineHandlerUVC : public PipelineHandler
> >  {
> >  public:
> > @@ -60,6 +63,9 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
> >  	}
> >  
> >  	if (!video_ || video_->open()) {
> > +		if (!video_)
> > +			LOG(UVC, Error) << "Could not find a default video device";
> > +
> >  		media_->release();
> >  		return false;
> >  	}
> > 
> 
> -- 
> Regards
> --
> Kieran

Patch

diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index c51e8bc1f2c2bf25..2ebdb2b9eb880174 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -8,12 +8,15 @@ 
 #include <libcamera/camera.h>
 
 #include "device_enumerator.h"
+#include "log.h"
 #include "media_device.h"
 #include "pipeline_handler.h"
 #include "v4l2_device.h"
 
 namespace libcamera {
 
+LOG_DEFINE_CATEGORY(UVC)
+
 class PipelineHandlerUVC : public PipelineHandler
 {
 public:
@@ -60,6 +63,9 @@  bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
 	}
 
 	if (!video_ || video_->open()) {
+		if (!video_)
+			LOG(UVC, Error) << "Could not find a default video device";
+
 		media_->release();
 		return false;
 	}