From 99e9fc2c535158329dd76b9cee5c6cb4b08547b6 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 15 Sep 2025 11:42:40 -0700 Subject: [PATCH] module_adapter: Count sinks/sources during bind In preparation for preparing modules during the bind phase instead of pipeline trigger, move the code to count of the sinks/sources as and when they are bound/unbound. Signed-off-by: Ranjani Sridharan --- src/audio/module_adapter/module/generic.c | 4 ++++ src/audio/module_adapter/module_adapter.c | 13 ------------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index f95299f952d8..52d3a98b789f 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -723,9 +723,11 @@ int module_bind(struct processing_module *mod, struct bind_info *bind_data) switch (bind_data->bind_type) { case COMP_BIND_TYPE_SINK: ret = sink_bind(bind_data->sink, mod); + mod->num_of_sinks++; break; case COMP_BIND_TYPE_SOURCE: ret = source_bind(bind_data->source, mod); + mod->num_of_sources++; break; default: ret = -EINVAL; @@ -747,9 +749,11 @@ int module_unbind(struct processing_module *mod, struct bind_info *unbind_data) switch (unbind_data->bind_type) { case COMP_BIND_TYPE_SINK: ret = sink_unbind(unbind_data->sink); + mod->num_of_sinks--; break; case COMP_BIND_TYPE_SOURCE: ret = source_unbind(unbind_data->source); + mod->num_of_sources--; break; default: ret = -EINVAL; diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index b77f57334401..2a1c806088c8 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -313,16 +313,6 @@ int module_adapter_prepare(struct comp_dev *dev) if (IS_PROCESSING_MODE_SINK_SOURCE(mod)) return 0; - /* compute number of input buffers */ - mod->num_of_sources = 0; - list_for_item(blist, &dev->bsource_list) - mod->num_of_sources++; - - /* compute number of output buffers */ - mod->num_of_sinks = 0; - list_for_item(blist, &dev->bsink_list) - mod->num_of_sinks++; - if (!mod->num_of_sources && !mod->num_of_sinks) { comp_err(dev, "no source and sink buffers connected!"); return -EINVAL; @@ -1222,9 +1212,6 @@ int module_adapter_reset(struct comp_dev *dev) if (IS_PROCESSING_MODE_RAW_DATA(mod) || IS_PROCESSING_MODE_AUDIO_STREAM(mod)) { rfree(mod->output_buffers); rfree(mod->input_buffers); - - mod->num_of_sources = 0; - mod->num_of_sinks = 0; } mod->total_data_consumed = 0;