Skip to content

Commit

Permalink
module: prepare sink & source in bind & unbind function
Browse files Browse the repository at this point in the history
Module will update source & sink information when bind & unbind
event happen.

Signed-off-by: Rander Wang <rander.wang@intel.com>
  • Loading branch information
RanderWang committed Dec 14, 2023
1 parent e8be072 commit 293abd0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/audio/module_adapter/module_adapter_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,35 @@ int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *valu
return 0;
}

static bool module_adapter_multi_sink_source_check(struct comp_dev *dev)
static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev)
{
struct processing_module *mod = comp_get_drvdata(dev);
struct list_item *blist;
int num_sources = 0;
int num_sinks = 0;
int i;

/* acquire all sink and source buffers, get handlers to sink/source API */
i = 0;
list_for_item(blist, &dev->bsink_list) {
struct comp_buffer *sink_buffer =
container_of(blist, struct comp_buffer, source_list);
mod->sinks[i] = audio_stream_get_sink(&sink_buffer->stream);
i++;
}
mod->num_of_sinks = i;

list_for_item(blist, &dev->bsource_list)
num_sources++;
i = 0;
list_for_item(blist, &dev->bsource_list) {
struct comp_buffer *source_buffer =
container_of(blist, struct comp_buffer, sink_list);

list_for_item(blist, &dev->bsink_list)
num_sinks++;
mod->sources[i] = audio_stream_get_source(&source_buffer->stream);
i++;
}
mod->num_of_sources = i;

comp_dbg(dev, "num_sources=%d num_sinks=%d", num_sources, num_sinks);
comp_dbg(dev, "num_sources=%d num_sinks=%d", mod->num_of_sinks, mod->num_of_sources);

if (num_sources != 1 || num_sinks != 1)
if (mod->num_of_sinks != 1 || mod->num_of_sources != 1)
return true;

/* re-assign the source/sink modules */
Expand All @@ -190,7 +203,7 @@ int module_adapter_bind(struct comp_dev *dev, void *data)
if (ret < 0)
return ret;

mod->stream_copy_single_to_single = !module_adapter_multi_sink_source_check(dev);
mod->stream_copy_single_to_single = !module_adapter_multi_sink_source_prepare(dev);

return 0;
}
Expand All @@ -204,7 +217,7 @@ int module_adapter_unbind(struct comp_dev *dev, void *data)
if (ret < 0)
return ret;

mod->stream_copy_single_to_single = !module_adapter_multi_sink_source_check(dev);
mod->stream_copy_single_to_single = !module_adapter_multi_sink_source_prepare(dev);

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/include/sof/audio/module_adapter/module/modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ static inline void declare_dynamic_module_adapter(struct comp_driver *drv,
drv->ops.set_large_config = module_set_large_config;
drv->ops.get_large_config = module_get_large_config;
drv->ops.get_attribute = module_adapter_get_attribute;
drv->ops.bind = module_adapter_bind;
drv->ops.unbind = module_adapter_unbind;
}

#endif /* __SOF_AUDIO_MODULES__ */

0 comments on commit 293abd0

Please sign in to comment.