From 41cdd8229121d9070a3b53a01e7aac5fb1758a3e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 4 Nov 2025 09:19:26 +0100 Subject: [PATCH] spa: ensure enum always has 2 values We need at least a default value and the default value as a possible value. For enum type in the PropInfo we usually list just the basic type and then use labels to list alternatives. --- spa/include/spa/pod/vararg.h | 2 +- spa/plugins/v4l2/v4l2-utils.c | 2 +- test/test-spa-pod.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spa/include/spa/pod/vararg.h b/spa/include/spa/pod/vararg.h index 8e9137df1..3434e9136 100644 --- a/spa/include/spa/pod/vararg.h +++ b/spa/include/spa/pod/vararg.h @@ -28,7 +28,7 @@ extern "C" { #define SPA_CHOICE_RANGE(def,min,max) 3,(def),(min),(max) #define SPA_CHOICE_STEP(def,min,max,step) 4,(def),(min),(max),(step) -#define SPA_CHOICE_ENUM(n_vals,...) (n_vals),##__VA_ARGS__ +#define SPA_CHOICE_ENUM(n_vals,def,alt1,...) (n_vals),(def),(alt1),##__VA_ARGS__ #define SPA_CHOICE_FLAGS(flags) 1, (flags) #define SPA_CHOICE_FEATURES(features) 1, (features) #define SPA_CHOICE_BOOL(def) 3,(def),(def),!(def) diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 9cfd0afae..ba071d2d5 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -1486,7 +1486,7 @@ spa_v4l2_enum_controls(struct impl *this, int seq, spa_pod_builder_push_object(&b.b, &f[0], SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo); spa_pod_builder_add(&b.b, SPA_PROP_INFO_id, SPA_POD_Id(prop_id), - SPA_PROP_INFO_type, SPA_POD_CHOICE_ENUM_Int(1, (int32_t)queryctrl.default_value), + SPA_PROP_INFO_type, SPA_POD_Int((int32_t)queryctrl.default_value), SPA_PROP_INFO_description, SPA_POD_String(queryctrl.name), 0); diff --git a/test/test-spa-pod.c b/test/test-spa-pod.c index 964844f75..03fee894b 100644 --- a/test/test-spa-pod.c +++ b/test/test-spa-pod.c @@ -1612,7 +1612,7 @@ PWTEST(pod_overflow) spa_pod_builder_push_object(&b, &f[0], SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo); spa_pod_builder_add(&b, SPA_PROP_INFO_id, SPA_POD_Id(32567359), - SPA_PROP_INFO_type, SPA_POD_CHOICE_ENUM_Int(1, 0), + SPA_PROP_INFO_type, SPA_POD_Int(0), SPA_PROP_INFO_description, SPA_POD_String("DV Timings"), 0); @@ -1669,7 +1669,7 @@ PWTEST(pod_overflow2) spa_pod_builder_push_object(&b, &f[0], SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo); spa_pod_builder_add(&b, SPA_PROP_INFO_id, SPA_POD_Id(32567359), - SPA_PROP_INFO_type, SPA_POD_CHOICE_ENUM_Int(1, 0), + SPA_PROP_INFO_type, SPA_POD_Int(0), SPA_PROP_INFO_description, SPA_POD_String("DV Timings"), 0);