diff options
Diffstat (limited to 'spa/plugins/volume/volume.c')
-rw-r--r-- | spa/plugins/volume/volume.c | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 17d8aafc..0eae0b30 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -26,8 +26,8 @@ #include <spa/list.h> #include <spa/audio/format-utils.h> #include <spa/param-alloc.h> -#include <lib/props.h> -#include <lib/format.h> + +#include <lib/pod.h> #define NAME "volume" @@ -143,6 +143,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); @@ -151,11 +153,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); } @@ -165,7 +170,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_volume, "dr", p->volume, 2, 0.0, 10.0, ":", t->prop_mute, "b", p->mute); @@ -175,6 +180,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; } @@ -318,21 +327,15 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); - int res; - struct spa_pod_object *fmt; - uint8_t buffer[1024]; - struct spa_pod_builder b = { NULL, }; struct type *t = &this->type; - 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, @@ -345,11 +348,6 @@ static int port_enum_formats(struct spa_node *node, 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; } @@ -357,7 +355,8 @@ 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_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; @@ -370,7 +369,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, @@ -391,6 +390,9 @@ impl_node_port_enum_params(struct spa_node *node, struct impl *this; struct type *t; struct port *port; + 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); @@ -403,6 +405,9 @@ impl_node_port_enum_params(struct spa_node *node, port = GET_PORT(this, direction, port_id); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -410,16 +415,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(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } 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, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idBuffers) { if (!port->have_format) @@ -427,7 +434,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, @@ -440,7 +447,7 @@ impl_node_port_enum_params(struct spa_node *node, else if (id == t->param.idMeta) { 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)); @@ -454,6 +461,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; } |