[libcamera-devel] [PATCH] libcamera: media_device: Use Loggable interface

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Feb 18 01:07:51 CET 2020


Hi Kieran,

Thank you for the patch.

On Mon, Feb 17, 2020 at 11:48:41PM +0000, Kieran Bingham wrote:
> Extend MediaDevice to inherit from the Loggable interface to support a
> logPrefix which presents the device node path, and the driver name.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
>  src/libcamera/include/media_device.h | 6 +++++-
>  src/libcamera/media_device.cpp       | 5 +++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
> index 7b88e2875d59..44a59e70139e 100644
> --- a/src/libcamera/include/media_device.h
> +++ b/src/libcamera/include/media_device.h
> @@ -16,11 +16,12 @@
>  
>  #include <libcamera/signal.h>
>  
> +#include "log.h"
>  #include "media_object.h"
>  
>  namespace libcamera {
>  
> -class MediaDevice
> +class MediaDevice : protected Loggable
>  {
>  public:
>  	MediaDevice(const std::string &deviceNode);
> @@ -52,6 +53,9 @@ public:
>  
>  	Signal<MediaDevice *> disconnected;
>  
> +protected:
> +	std::string logPrefix() const;
> +
>  private:
>  	std::string driver_;
>  	std::string deviceNode_;
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index e1ae34f88455..fad475b9ac76 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -74,6 +74,11 @@ MediaDevice::~MediaDevice()
>  	clear();
>  }
>  
> +std::string MediaDevice::logPrefix() const
> +{
> +	return deviceNode() + "[" + driver() + "]";

Before MediaDevice::populate is called, this will print "/dev/mediaX[]".
I suppose that's not a problem.

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

> +}
> +
>  /**
>   * \brief Claim a device for exclusive use
>   *

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list