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

@ -277,29 +277,30 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct type *t = &this->type;
struct spa_pod_builder_state state;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
struct spa_pod *param;
int res;
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 };
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, filter, &param, builder)) <= 0)
if ((res = port_enum_formats(node, direction, port_id, index, filter, &param, &b)) <= 0)
return res;
}
else if (id == t->param.idFormat) {
if ((res = port_get_format(node, direction, port_id, index, filter, &param, builder)) <= 0)
if ((res = port_get_format(node, direction, port_id, index, filter, &param, &b)) <= 0)
return res;
}
else
@ -307,7 +308,6 @@ spa_ffmpeg_dec_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;

View file

@ -273,29 +273,30 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct type *t = &this->type;
struct spa_pod_builder_state state;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
struct spa_pod *param;
int res;
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 };
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, filter, &param, builder)) <= 0)
if ((res = port_enum_formats(node, direction, port_id, index, filter, &param, &b)) <= 0)
return res;
}
else if (id == t->param.idFormat) {
if ((res = port_get_format(node, direction, port_id, index, filter, &param, builder)) <= 0)
if ((res = port_get_format(node, direction, port_id, index, filter, &param, &b)) <= 0)
return res;
}
else
@ -303,7 +304,6 @@ spa_ffmpeg_enc_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;