gst: simplify modifier extraction

spa_pod_get_values() handles both single values and Choice values and
turns the single value into a None choice.

Check that we have a None or Enum choice because we don't handle
anything else.

See !1952
This commit is contained in:
Wim Taymans 2024-03-28 16:09:18 +01:00
parent 8848c7e792
commit e3227b2b5d
1 changed files with 12 additions and 17 deletions

View File

@ -877,11 +877,13 @@ handle_dmabuf_prop (const struct spa_pod_prop *prop,
const struct spa_pod *pod_modifier;
struct spa_pod *val;
uint32_t *id, n_fmts, n_mods, choice, i, j;
uint64_t *mods, single_modifier;
uint64_t *mods;
val = spa_pod_get_values (&prop->value, &n_fmts, &choice);
if (val->type != SPA_TYPE_Id)
return;
if (choice != SPA_CHOICE_None && choice != SPA_CHOICE_Enum)
return;
id = SPA_POD_BODY (val);
if (n_fmts > 1) {
@ -889,23 +891,16 @@ handle_dmabuf_prop (const struct spa_pod_prop *prop,
id++;
}
pod_modifier = &prop_modifier->value;
if (spa_pod_is_long (pod_modifier) &&
spa_pod_get_long (pod_modifier, (int64_t *) &single_modifier)) {
mods = &single_modifier;
n_mods = 1;
} else if (spa_pod_is_choice (pod_modifier) &&
SPA_POD_CHOICE_TYPE (pod_modifier) == SPA_CHOICE_Enum &&
SPA_POD_CHOICE_VALUE_TYPE (pod_modifier) == SPA_TYPE_Long) {
mods = SPA_POD_CHOICE_VALUES (pod_modifier);
n_mods = SPA_POD_CHOICE_N_VALUES (pod_modifier);
if (n_mods > 1) {
n_mods--;
mods++;
}
} else {
pod_modifier = spa_pod_get_values (&prop_modifier->value, &n_mods, &choice);
if (pod_modifier->type != SPA_TYPE_Long)
return;
if (choice != SPA_CHOICE_None && choice != SPA_CHOICE_Enum)
return;
mods = SPA_POD_BODY (pod_modifier);
if (n_mods > 1) {
n_mods--;
mods++;
}
fmt_array = g_ptr_array_new_with_free_func (g_free);