Implement param filtering

Make a new pod filter function and use it in the plugins to filter
in enum_params.
Small tweaks to the pod_builder
This commit is contained in:
Wim Taymans 2017-11-09 17:07:04 +01:00
parent cc47fb7e3a
commit 58451d626c
35 changed files with 1150 additions and 917 deletions

View file

@ -32,8 +32,7 @@
#include <spa/list.h>
#include <spa/audio/format-utils.h>
#include <lib/format.h>
#include <lib/props.h>
#include <lib/pod.h>
#define NAME "audiotestsrc"
@ -173,6 +172,8 @@ static int impl_node_enum_params(struct spa_node *node,
{
struct impl *this;
struct type *t;
uint32_t offset;
struct spa_pod *param;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -181,11 +182,14 @@ static int impl_node_enum_params(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
offset = builder->offset;
next:
if (id == t->param.idList) {
if (*index > 0)
return SPA_RESULT_ENUM_END;
spa_pod_builder_object(builder,
param = spa_pod_builder_object(builder,
id, t->param.List,
":", t->param.listId, "I", t->param.idProps);
}
@ -195,7 +199,7 @@ static int impl_node_enum_params(struct spa_node *node,
if (*index > 0)
return SPA_RESULT_ENUM_END;
spa_pod_builder_object(builder,
param = spa_pod_builder_object(builder,
id, t->props,
":", t->prop_live, "b", p->live,
":", t->prop_wave, "Ie", p->wave,
@ -211,6 +215,10 @@ static int impl_node_enum_params(struct spa_node *node,
(*index)++;
spa_pod_builder_reset(builder, offset);
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
goto next;
return SPA_RESULT_OK;
}
@ -507,21 +515,14 @@ static int
port_enum_formats(struct impl *this,
enum spa_direction direction, uint32_t port_id,
uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct spa_pod_object *fmt;
struct type *t = &this->type;
uint8_t buffer[1024];
struct spa_pod_builder b = { 0 };
int res;
next:
spa_pod_builder_init(&b, buffer, sizeof(buffer));
switch (*index) {
case 0:
fmt = spa_pod_builder_object(&b,
*param = spa_pod_builder_object(builder,
t->param.idEnumFormat, t->format,
"I", t->media_type.audio,
"I", t->media_subtype.raw,
@ -538,12 +539,6 @@ port_enum_formats(struct impl *this,
default:
return SPA_RESULT_ENUM_END;
}
(*index)++;
if ((res = spa_pod_object_filter(fmt, filter, builder)) != SPA_RESULT_OK)
goto next;
return SPA_RESULT_OK;
}
@ -552,7 +547,7 @@ port_get_format(struct impl *this,
enum spa_direction direction,
uint32_t port_id,
uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct type *t = &this->type;
@ -563,7 +558,7 @@ port_get_format(struct impl *this,
if (*index > 0)
return SPA_RESULT_ENUM_END;
spa_pod_builder_object(builder,
*param = spa_pod_builder_object(builder,
t->param.idFormat, t->format,
"I", t->media_type.audio,
"I", t->media_subtype.raw,
@ -583,6 +578,9 @@ impl_node_port_enum_params(struct spa_node *node,
{
struct impl *this;
struct type *t;
uint32_t offset;
struct spa_pod *param;
int res;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -593,6 +591,9 @@ impl_node_port_enum_params(struct spa_node *node,
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
offset = builder->offset;
next:
if (id == t->param.idList) {
uint32_t list[] = { t->param.idEnumFormat,
t->param.idFormat,
@ -600,16 +601,18 @@ impl_node_port_enum_params(struct spa_node *node,
t->param.idMeta };
if (*index < SPA_N_ELEMENTS(list))
spa_pod_builder_object(builder, id, t->param.List,
param = spa_pod_builder_object(builder, id, t->param.List,
":", t->param.listId, "I", list[*index]);
else
return SPA_RESULT_ENUM_END;
}
else if (id == t->param.idEnumFormat) {
return port_enum_formats(this, direction, port_id, index, filter, builder);
if ((res = port_enum_formats(this, direction, port_id, index, &param, builder)) < 0)
return res;
}
else if (id == t->param.idFormat) {
return port_get_format(this, direction, port_id, index, filter, builder);
if ((res = port_get_format(this, direction, port_id, index, &param, builder)) < 0)
return res;
}
else if (id == t->param.idBuffers) {
if (!this->have_format)
@ -617,7 +620,7 @@ impl_node_port_enum_params(struct spa_node *node,
if (*index > 0)
return SPA_RESULT_ENUM_END;
spa_pod_builder_object(builder,
param = spa_pod_builder_object(builder,
id, t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "iru", 1024 * this->bpf,
2, 16 * this->bpf,
@ -633,13 +636,13 @@ impl_node_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
spa_pod_builder_object(builder,
param = spa_pod_builder_object(builder,
id, t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
case 1:
spa_pod_builder_object(builder,
param = spa_pod_builder_object(builder,
id, t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Ringbuffer,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_ringbuffer),
@ -658,6 +661,10 @@ impl_node_port_enum_params(struct spa_node *node,
(*index)++;
spa_pod_builder_reset(builder, offset);
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
goto next;
return SPA_RESULT_OK;
}