From a1cc0f3d864537a68492513ac8463daa02908fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 23 Jul 2025 14:12:12 +0200 Subject: [PATCH] spa: libcamera: source: rework bool control type info `SPA_POD_CHOICE_Bool()` assumes that both true and false are available, which may not be the case for libcamera controls, so manualy construct the enumerated choice object and only add the actually available options. (cherry picked from commit 66cc01ee2d28e0cfc546f09122ad8252362281e3) --- spa/plugins/libcamera/libcamera-source.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index 893301752..288cc9b3b 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -754,16 +754,20 @@ spa_pod *control_details_to_pod(spa_pod_builder& b, switch (cid.type()) { case ControlTypeBool: { - bool def; - if (cinfo.def().isNone()) - def = cinfo.min().get(); - else - def = cinfo.def().get(); + auto min = cinfo.min().get(); + auto max = cinfo.max().get(); + auto def = !cinfo.def().isNone() + ? cinfo.def().get() + : min; + spa_pod_frame f; - spa_pod_builder_add(&b, - SPA_PROP_INFO_type, SPA_POD_CHOICE_Bool( - def), - 0); + spa_pod_builder_prop(&b, SPA_PROP_INFO_type, 0); + spa_pod_builder_push_choice(&b, &f, SPA_CHOICE_Enum, 0); + spa_pod_builder_bool(&b, def); + spa_pod_builder_bool(&b, min); + if (max != min) + spa_pod_builder_bool(&b, max); + spa_pod_builder_pop(&b, &f); } break; case ControlTypeFloat: { float min = cinfo.min().get();