pipewire issueshttps://gitlab.freedesktop.org/pipewire/pipewire/-/issues2021-12-30T16:38:09Zhttps://gitlab.freedesktop.org/pipewire/pipewire/-/issues/226spa_pod_filter silently requires a newly initialized builder2021-12-30T16:38:09ZGeorge Kiagiadakisspa_pod_filter silently requires a newly initialized builderNot sure if this is a bug or something that just needs to be documented, but I observed this awkward behavior in this code:
```
char buf[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
g_autoptr (GPtrArray) pa...Not sure if this is a bug or something that just needs to be documented, but I observed this awkward behavior in this code:
```
char buf[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
g_autoptr (GPtrArray) params =
wp_spa_props_build_propinfo (&priv->spa_props, &b);
for (guint i = start; i < params->len; i++) {
struct spa_pod *param = g_ptr_array_index (params, i);
if (spa_pod_filter (&b, &result, param, filter) == 0) {
pw_session_emit_param (&self->hooks, seq, id, i, i+1, result);
if (++count == num)
break;
}
}
```
`wp_spa_props_build_propinfo` essentially builds an array of `spa_pod*` that contains all the PropInfo params. Then I iterate over it and filter it, using the same builder. What actually happens here is that the `result` spa_pod is always the same and equals the very first `spa_pod*` in the `params` array.
The reason is that `spa_pod_filter()` internally does: `*result = (struct spa_pod*)b->data;`,
so if the builder is shared to build something else before calling `spa_pod_filter()`, the result of the filter is wrong.Wim TaymansWim Taymanshttps://gitlab.freedesktop.org/pipewire/pipewire/-/issues/196Awkwardness in parsing pod choice2021-12-30T16:38:07ZGeorge KiagiadakisAwkwardness in parsing pod choiceFirst, create a pod:
```
pod = spa_pod_builder_add_object (b,
SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
SPA_PROP_INFO_id, SPA_POD_Id (Foo),
SPA_PROP_INFO_name, SPA_POD_String ("Bar"),
SPA_PROP_INFO_t...First, create a pod:
```
pod = spa_pod_builder_add_object (b,
SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
SPA_PROP_INFO_id, SPA_POD_Id (Foo),
SPA_PROP_INFO_name, SPA_POD_String ("Bar"),
SPA_PROP_INFO_type, SPA_POD_CHOICE_RANGE_Float (1.0, 0.0, 1.0));
```
Then try to parse it in a generic way (because we don't know what the type is):
```
spa_pod_parse_object (pod,
SPA_TYPE_OBJECT_PropInfo, NULL,
SPA_PROP_INFO_id, SPA_POD_Id (&id),
SPA_PROP_INFO_name, SPA_POD_String (&name),
SPA_PROP_INFO_type, SPA_POD_Pod (&pod));
```
One would expect now that `SPA_POD_TYPE (pod) == SPA_TYPE_Choice`, but in fact the parser returns the first child of the range, so `SPA_POD_TYPE (pod) == SPA_TYPE_Float`Wim TaymansWim Taymans