- ret = auto_name_components_in_array(cfg, cfg->cmd_data.convert.filters,
- "filter");
- if (ret) {
- goto end;
- }
-
- ret = auto_name_components_in_array(cfg, cfg->cmd_data.convert.sinks,
- "sink");
- if (ret) {
- goto end;
- }
-
-end:
- return ret;
-}
-
-static int auto_connect(struct bt_config *cfg)
-{
- int ret = 0;
- struct bt_config_component *muxer_cfg_comp = NULL;
- size_t i;
- const char *last_filter_comp_name;
-
- /* Make sure all components have a unique instance name */
- ret = auto_name_components(cfg);
- if (ret) {
- goto error;
- }
-
- /* Add an implicit muxer filter */
- muxer_cfg_comp = bt_config_component_from_arg(
- BT_COMPONENT_CLASS_TYPE_FILTER, "utils.muxer");
- if (!muxer_cfg_comp) {
- goto error;
- }
-
- auto_name_component(cfg, "filter", muxer_cfg_comp);
- g_ptr_array_add(cfg->cmd_data.convert.filters, bt_get(muxer_cfg_comp));
-
- /* Connect all sources to this mux */
- for (i = 0; i < cfg->cmd_data.convert.sources->len; i++) {
- struct bt_config_component *comp =
- g_ptr_array_index(cfg->cmd_data.convert.sources, i);
- struct bt_config_connection *cfg_connection =
- bt_config_connection_create_full(
- comp->instance_name->str, "",
- muxer_cfg_comp->instance_name->str, "",
- "(auto)");
-
- if (!cfg_connection) {
- goto error;
- }
-
- g_ptr_array_add(cfg->cmd_data.convert.connections,
- cfg_connection);
- }
-
- /* Connect this mux to the filter components, in order */
- last_filter_comp_name = muxer_cfg_comp->instance_name->str;
-
- for (i = 0; i < cfg->cmd_data.convert.filters->len - 1; i++) {
- struct bt_config_component *comp =
- g_ptr_array_index(cfg->cmd_data.convert.filters, i);
- struct bt_config_connection *cfg_connection;
-
- cfg_connection = bt_config_connection_create_full(
- last_filter_comp_name, "",
- comp->instance_name->str, "",
- "(auto)");
-
- if (!cfg_connection) {
- goto error;
- }
-
- g_ptr_array_add(cfg->cmd_data.convert.connections,
- cfg_connection);
- last_filter_comp_name = comp->instance_name->str;
- }
-
- /* Connect the last filter component to all sink components */
- for (i = 0; i < cfg->cmd_data.convert.sinks->len; i++) {
- struct bt_config_component *comp =
- g_ptr_array_index(cfg->cmd_data.convert.sinks, i);
- struct bt_config_connection *cfg_connection =
- bt_config_connection_create_full(
- last_filter_comp_name, "",
- comp->instance_name->str, "",
- "(auto)");
-
- if (!cfg_connection) {
- goto error;
- }
-
- g_ptr_array_add(cfg->cmd_data.convert.connections,
- cfg_connection);
- }
-
- goto end;
-
-error:
- ret = -1;
-