From 52a3a8817d08f5b432a9cc10a48ad37249dab368 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 27 Dec 2021 10:42:49 -0300 Subject: [PATCH] linux-capture: Add preferred value out of the loop Choice pods are built with the first element being the preferred choice, followed by a list of possible choices. We add the preferred choice inside the loop, which makes the code slightly harder to follow. Factor this out of the loop, into a separate step. --- plugins/linux-capture/pipewire.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/linux-capture/pipewire.c b/plugins/linux-capture/pipewire.c index 56f45a8ce..1d0560021 100644 --- a/plugins/linux-capture/pipewire.c +++ b/plugins/linux-capture/pipewire.c @@ -409,14 +409,18 @@ static inline struct spa_pod *build_format(struct spa_pod_builder *b, spa_pod_builder_prop(b, SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE); + spa_pod_builder_push_choice(b, &f[1], SPA_CHOICE_Enum, 0); + + /* The first element of choice pods is the preferred value. Here + * we arbitrarily pick the first modifier as the preferred one. + */ + spa_pod_builder_long(b, modifiers[0]); + /* modifiers from an array */ - for (uint32_t i = 0; i < modifier_count; i++) { - uint64_t modifier = modifiers[i]; - spa_pod_builder_long(b, modifier); - if (i == 0) - spa_pod_builder_long(b, modifier); - } + for (uint32_t i = 0; i < modifier_count; i++) + spa_pod_builder_long(b, modifiers[i]); + spa_pod_builder_pop(b, &f[1]); } /* add size and framerate ranges */