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

@ -24,7 +24,8 @@
#include <spa/node.h>
#include <spa/list.h>
#include <spa/audio/format.h>
#include <lib/props.h>
#include <lib/pod.h>
#define NAME "alsa-source"
@ -48,6 +49,8 @@ static int impl_node_enum_params(struct spa_node *node,
{
struct state *this;
struct type *t;
struct spa_pod *param;
uint32_t offset;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -56,11 +59,14 @@ static int impl_node_enum_params(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct state, 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);
}
@ -70,7 +76,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_device, "S", p->device, sizeof(p->device),
":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name),
@ -83,6 +89,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;
}
@ -290,7 +300,7 @@ static void recycle_buffer(struct state *this, uint32_t buffer_id)
static int port_get_format(struct spa_node *node,
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 state *this = SPA_CONTAINER_OF(node, struct state, node);
@ -301,7 +311,7 @@ static int port_get_format(struct spa_node *node,
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,
@ -321,6 +331,9 @@ impl_node_port_enum_params(struct spa_node *node,
{
struct state *this;
struct type *t;
struct spa_pod *param;
uint32_t offset;
int res;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -331,6 +344,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,
@ -338,7 +354,7 @@ 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;
@ -347,7 +363,8 @@ impl_node_port_enum_params(struct spa_node *node,
return spa_alsa_enum_format(this, index, filter, builder);
}
else if (id == t->param.idFormat) {
return port_get_format(node, direction, port_id, index, filter, builder);
if ((res = port_get_format(node, direction, port_id, index, &param, builder)) < 0)
return res;
}
else if (id == t->param.idBuffers) {
if (!this->have_format)
@ -355,7 +372,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, "i", this->props.min_latency * this->frame_size,
":", t->param_alloc_buffers.stride, "i", 0,
@ -369,7 +386,7 @@ 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));
@ -383,6 +400,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;
}