[libcamera-devel,v5,3/9] android: metadata: Fix addEntry template type
diff mbox series

Message ID 20210720101307.26010-4-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • android: Support capability and hardware level detection
Related show

Commit Message

Paul Elder July 20, 2021, 10:13 a.m. UTC
Since we set entries with android tags directly, which are enums and not
arithmetic types, the addEntry template fails to match. Fix this by also
allowing enum values in addEntry.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

---
New in v4
---
 src/android/camera_metadata.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart July 25, 2021, 12:38 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Tue, Jul 20, 2021 at 07:13:01PM +0900, Paul Elder wrote:
> Since we set entries with android tags directly, which are enums and not
> arithmetic types, the addEntry template fails to match. Fix this by also
> allowing enum values in addEntry.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
> New in v4
> ---
>  src/android/camera_metadata.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h
> index 72ba4db2..6e51efb5 100644
> --- a/src/android/camera_metadata.h
> +++ b/src/android/camera_metadata.h
> @@ -44,7 +44,8 @@ public:
>  	bool hasEntry(uint32_t tag) const;
>  
>  	template<typename T,
> -		 std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
> +		 std::enable_if_t<std::is_arithmetic_v<T> ||
> +				  std::is_enum_v<T>> * = nullptr>
>  	bool addEntry(uint32_t tag, const T &data)
>  	{
>  		return addEntry(tag, &data, 1, sizeof(T));

Patch
diff mbox series

diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h
index 72ba4db2..6e51efb5 100644
--- a/src/android/camera_metadata.h
+++ b/src/android/camera_metadata.h
@@ -44,7 +44,8 @@  public:
 	bool hasEntry(uint32_t tag) const;
 
 	template<typename T,
-		 std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
+		 std::enable_if_t<std::is_arithmetic_v<T> ||
+				  std::is_enum_v<T>> * = nullptr>
 	bool addEntry(uint32_t tag, const T &data)
 	{
 		return addEntry(tag, &data, 1, sizeof(T));