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 66cc01ee2d)
This commit is contained in:
Barnabás Pőcze 2025-07-23 14:12:12 +02:00 committed by Robert Mader
parent f6d3db72a1
commit a1cc0f3d86

View file

@ -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<bool>();
else
def = cinfo.def().get<bool>();
auto min = cinfo.min().get<bool>();
auto max = cinfo.max().get<bool>();
auto def = !cinfo.def().isNone()
? cinfo.def().get<bool>()
: 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<float>();