diff options
Diffstat (limited to 'src/modules/module-audio-dsp/floatmix.c')
-rw-r--r-- | src/modules/module-audio-dsp/floatmix.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/src/modules/module-audio-dsp/floatmix.c b/src/modules/module-audio-dsp/floatmix.c index 750ae81c..fc35cf4e 100644 --- a/src/modules/module-audio-dsp/floatmix.c +++ b/src/modules/module-audio-dsp/floatmix.c @@ -122,10 +122,9 @@ struct impl { #define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p)) static int impl_node_enum_params(struct spa_node *node, - uint32_t id, uint32_t *index, + uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter, - struct spa_pod **param, - struct spa_pod_builder *builder) + spa_result_func_t func, void *data) { return -ENOTSUP; } @@ -274,13 +273,13 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3 static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, - uint32_t *index, + uint32_t index, struct spa_pod **param, struct spa_pod_builder *builder) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); - switch (*index) { + switch (index) { case 0: if (this->have_format) { *param = spa_format_audio_raw_build(builder, SPA_PARAM_EnumFormat, @@ -304,21 +303,22 @@ static int port_enum_formats(struct spa_node *node, static int impl_node_port_enum_params(struct spa_node *node, enum spa_direction direction, uint32_t port_id, - uint32_t id, uint32_t *index, + uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter, - struct spa_pod **result, - struct spa_pod_builder *builder) + spa_result_func_t func, void *data) { struct impl *this; struct port *port; struct spa_pod *param; struct spa_pod_builder b = { 0 }; uint8_t buffer[1024]; + struct spa_result_node_enum_params result; + uint32_t count = 0; int res; spa_return_val_if_fail(node != NULL, -EINVAL); - spa_return_val_if_fail(index != NULL, -EINVAL); - spa_return_val_if_fail(builder != NULL, -EINVAL); + spa_return_val_if_fail(num != 0, -EINVAL); + spa_return_val_if_fail(func != NULL, -EINVAL); this = SPA_CONTAINER_OF(node, struct impl, node); @@ -326,6 +326,8 @@ impl_node_port_enum_params(struct spa_node *node, port = GET_PORT(this, direction, port_id); + result.next = start; + next: spa_pod_builder_init(&b, buffer, sizeof(buffer)); @@ -338,32 +340,32 @@ impl_node_port_enum_params(struct spa_node *node, SPA_PARAM_Meta, SPA_PARAM_IO }; - if (*index < SPA_N_ELEMENTS(list)) + if (result.next < SPA_N_ELEMENTS(list)) param = spa_pod_builder_add_object(&b, SPA_TYPE_OBJECT_ParamList, id, - SPA_PARAM_LIST_id, SPA_POD_Id(list[*index])); + SPA_PARAM_LIST_id, SPA_POD_Id(list[result.next])); else return 0; break; } case SPA_PARAM_EnumFormat: - if ((res = port_enum_formats(node, direction, port_id, index, ¶m, &b)) <= 0) + if ((res = port_enum_formats(node, direction, port_id, result.next, ¶m, &b)) <= 0) return res; break; case SPA_PARAM_Format: if (!port->have_format) return -EIO; - if (*index > 0) + if (result.next > 0) return 0; - param = spa_format_audio_raw_build(builder, id, &this->format.info.raw); + param = spa_format_audio_raw_build(&b, id, &this->format.info.raw); break; case SPA_PARAM_Buffers: if (!port->have_format) return -EIO; - if (*index > 0) + if (result.next > 0) return 0; param = spa_pod_builder_add_object(&b, @@ -382,7 +384,7 @@ impl_node_port_enum_params(struct spa_node *node, if (!port->have_format) return -EIO; - switch (*index) { + switch (result.next) { case 0: param = spa_pod_builder_add_object(&b, SPA_TYPE_OBJECT_ParamMeta, id, @@ -395,7 +397,7 @@ impl_node_port_enum_params(struct spa_node *node, break; case SPA_PARAM_IO: - switch (*index) { + switch (result.next) { case 0: param = spa_pod_builder_add_object(&b, SPA_TYPE_OBJECT_ParamIO, id, @@ -422,12 +424,18 @@ impl_node_port_enum_params(struct spa_node *node, return -ENOENT; } - (*index)++; + result.next++; - if (spa_pod_filter(builder, result, param, filter) < 0) + if (spa_pod_filter(&b, &result.param, param, filter) < 0) goto next; - return 1; + if ((res = func(data, count, 1, &result)) != 0) + return res; + + if (++count != num) + goto next; + + return 0; } static int clear_buffers(struct impl *this, struct port *port) |