- BT_LOGD("Connecting component ports: "
- "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
- "downstream-comp-addr=%p, downstream-comp-name=\"%s\"",
- upstream_component, bt_component_get_name(upstream_component),
- downstream_component, bt_component_get_name(downstream_component));
+end:
+ return (void *) graph;
+
+error:
+ BT_OBJECT_PUT_REF_AND_RESET(graph);
+ goto end;
+}
+
+enum bt_graph_status bt_graph_connect_ports(
+ struct bt_graph *graph,
+ const struct bt_port_output *upstream_port_out,
+ const struct bt_port_input *downstream_port_in,
+ const struct bt_connection **user_connection)
+{
+ enum bt_graph_status status = BT_GRAPH_STATUS_OK;
+ struct bt_connection *connection = NULL;
+ struct bt_port *upstream_port = (void *) upstream_port_out;
+ struct bt_port *downstream_port = (void *) downstream_port_in;
+ struct bt_component *upstream_component = NULL;
+ struct bt_component *downstream_component = NULL;
+ enum bt_self_component_status component_status;
+ bool init_can_consume;
+
+ BT_ASSERT_PRE_NON_NULL(graph, "Graph");
+ BT_ASSERT_PRE_NON_NULL(upstream_port, "Upstream port");
+ BT_ASSERT_PRE_NON_NULL(downstream_port, "Downstream port port");
+ BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
+ BT_ASSERT_PRE(
+ graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
+ "Graph is not in the \"configuring\" state: %!+g", graph);
+ BT_ASSERT_PRE(!bt_port_is_connected(upstream_port),
+ "Upstream port is already connected: %!+p", upstream_port);
+ BT_ASSERT_PRE(!bt_port_is_connected(downstream_port),
+ "Downstream port is already connected: %!+p", downstream_port);
+ BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) upstream_port),
+ "Upstream port does not belong to a component: %!+p",
+ upstream_port);
+ BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) downstream_port),
+ "Downstream port does not belong to a component: %!+p",
+ downstream_port);
+ init_can_consume = graph->can_consume;
+ BT_LIB_LOGD("Connecting component ports within graph: "
+ "%![graph-]+g, %![up-port-]+p, %![down-port-]+p",
+ graph, upstream_port, downstream_port);
+ bt_graph_set_can_consume(graph, false);
+ upstream_component = bt_port_borrow_component_inline(
+ (void *) upstream_port);
+ downstream_component = bt_port_borrow_component_inline(
+ (void *) downstream_port);