spa_pod_filter silently requires a newly initialized builder
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.