- bool init_can_consume;
- uint64_t count;
- uint64_t i;
- int ret = 0;
-
- BT_ASSERT(graph);
- BT_ASSERT(component);
- BT_ASSERT(component->base.ref_count == 0);
- BT_ASSERT(bt_component_borrow_graph(component) == graph);
-
- init_can_consume = graph->can_consume;
- count = bt_component_get_input_port_count(component);
-
- for (i = 0; i < count; i++) {
- struct bt_port *port = (void *)
- bt_component_borrow_input_port_by_index(component, i);
-
- BT_ASSERT(port);
-
- if (bt_port_is_connected(port)) {
- BT_LIB_LOGW("Cannot remove component from graph: "
- "an input port is connected: "
- "%![graph-]+g, %![comp-]+c, %![port-]+p",
- graph, component, port);
- goto error;
- }
- }
-
- count = bt_component_get_output_port_count(component);
-
- for (i = 0; i < count; i++) {
- struct bt_port *port = (void *)
- bt_component_borrow_output_port_by_index(component, i);
-
- BT_ASSERT(port);
-
- if (bt_port_is_connected(port)) {
- BT_LIB_LOGW("Cannot remove component from graph: "
- "an output port is connected: "
- "%![graph-]+g, %![comp-]+c, %![port-]+p",
- graph, component, port);
- goto error;
- }
- }
-
- bt_graph_set_can_consume(graph, false);
-
- /* Possibly remove from sinks to consume */
- (void) g_queue_remove(graph->sinks_to_consume, component);
-
- if (graph->sinks_to_consume->length == 0) {
- graph->has_sink = false;
- }
+ enum bt_graph_add_component_status status;
+ struct bt_component_class_sink *comp_cls;
+ struct simple_sink_init_method_data init_method_data = {
+ .init_func = init_func,
+ .consume_func = consume_func,
+ .finalize_func = finalize_func,
+ .user_data = user_data,
+ };