Improve pod filter

Reset the builder when the filter failed.
Make the plugins create their params in a temporary buffer, we
don't want to do in-place filtering because that is not always
possible. Because the filter now resets on error, we can remove
the reset from the plugins.
This commit is contained in:
Wim Taymans 2017-11-14 10:17:45 +01:00
parent 7a7c011b00
commit 52e1dad93e
15 changed files with 193 additions and 226 deletions

View file

@ -389,7 +389,8 @@ impl_node_port_enum_params(struct spa_node *node,
struct type *t;
struct port *port;
struct spa_pod *param;
struct spa_pod_builder_state state;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
int res;
spa_return_val_if_fail(node != NULL, -EINVAL);
@ -403,9 +404,9 @@ impl_node_port_enum_params(struct spa_node *node,
port = GET_PORT(this, direction, port_id);
spa_pod_builder_get_state(builder, &state);
next:
spa_pod_builder_init(&b, buffer, sizeof(buffer));
if (id == t->param.idList) {
uint32_t list[] = { t->param.idEnumFormat,
t->param.idFormat,
@ -413,17 +414,17 @@ impl_node_port_enum_params(struct spa_node *node,
t->param.idMeta };
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(builder, id, t->param.List,
param = spa_pod_builder_object(&b, id, t->param.List,
":", t->param.listId, "I", list[*index]);
else
return 0;
}
else if (id == t->param.idEnumFormat) {
if ((res = port_enum_formats(node, direction, port_id, index, &param, builder)) <= 0)
if ((res = port_enum_formats(node, direction, port_id, index, &param, &b)) <= 0)
return res;
}
else if (id == t->param.idFormat) {
if ((res = port_get_format(node, direction, port_id, index, &param, builder)) <= 0)
if ((res = port_get_format(node, direction, port_id, index, &param, &b)) <= 0)
return res;
}
else if (id == t->param.idBuffers) {
@ -432,7 +433,7 @@ impl_node_port_enum_params(struct spa_node *node,
if (*index > 0)
return 0;
param = spa_pod_builder_object(builder,
param = spa_pod_builder_object(&b,
id, t->param_buffers.Buffers,
":", t->param_buffers.size, "iru", 1024 * this->bpf,
2, 16 * this->bpf,
@ -448,13 +449,13 @@ impl_node_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_object(&b,
id, t->param_meta.Meta,
":", t->param_meta.type, "I", t->meta.Header,
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
break;
case 1:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_object(&b,
id, t->param_meta.Meta,
":", t->param_meta.type, "I", t->meta.Ringbuffer,
":", t->param_meta.size, "i", sizeof(struct spa_meta_ringbuffer),
@ -473,7 +474,6 @@ impl_node_port_enum_params(struct spa_node *node,
(*index)++;
spa_pod_builder_reset(builder, &state);
if (spa_pod_filter(builder, result, param, filter) < 0)
goto next;