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.
This commit is contained in:
Georges Basile Stavracas Neto 2021-12-27 10:42:49 -03:00 committed by Georges Basile Stavracas Neto
parent 37ba341d3a
commit 52a3a8817d

View File

@ -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 */