g_ptr_array_free(connection->iterators, TRUE);
/*
- * No bt_put on ports as a connection only holds _weak_
+ * No bt_object_put_ref on ports as a connection only holds _weak_
* references to them.
*/
g_free(connection);
static
void bt_connection_try_remove_from_graph(struct bt_connection *connection)
{
- void *graph = bt_object_borrow_parent(&connection->base);
+ void *graph = (void *) bt_object_borrow_parent(&connection->base);
- if (connection->base.ref_count.count > 0 ||
+ if (connection->base.ref_count > 0 ||
connection->downstream_port ||
connection->upstream_port ||
connection->iterators->len > 0) {
bt_connection_try_remove_from_graph(connection);
}
-struct bt_connection *bt_connection_from_private(
+struct bt_connection *bt_connection_borrow_from_private(
struct bt_private_connection *private_connection)
{
- return bt_get(bt_connection_borrow_from_private(private_connection));
+ return (void *) private_connection;
}
BT_HIDDEN
goto end;
}
- bt_object_init(connection, bt_connection_destroy);
- bt_object_set_parent_is_owner_listener(connection,
+ bt_object_init_shared_with_parent(&connection->base,
+ bt_connection_destroy);
+ bt_object_set_parent_is_owner_listener_func(&connection->base,
bt_connection_parent_is_owner);
connection->iterators = g_ptr_array_new();
if (!connection->iterators) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
- BT_PUT(connection);
+ BT_OBJECT_PUT_REF_AND_RESET(connection);
goto end;
}
bt_port_set_connection(upstream_port, connection);
BT_LOGD_STR("Setting downstream port's connection.");
bt_port_set_connection(downstream_port, connection);
- bt_object_set_parent(connection, &graph->base);
+ bt_object_set_parent(&connection->base, &graph->base);
BT_LOGD("Created connection: "
"graph-addr=%p, upstream-port-addr=%p, uptream-port-name=\"%s\", "
"downstream-port-addr=%p, downstream-port-name=\"%s\", "
conn->upstream_port = NULL;
}
- if (downstream_comp) {
+ if (downstream_comp && conn->notified_downstream_port_connected) {
/* bt_component_port_disconnected() logs details */
bt_component_port_disconnected(downstream_comp,
downstream_port);
}
- if (upstream_comp) {
+ if (upstream_comp && conn->notified_upstream_port_connected) {
/* bt_component_port_disconnected() logs details */
bt_component_port_disconnected(upstream_comp, upstream_port);
}
BT_ASSERT(graph);
- /* bt_graph_notify_ports_disconnected() logs details */
- bt_graph_notify_ports_disconnected(graph, upstream_comp,
- downstream_comp, upstream_port, downstream_port);
- bt_put(downstream_comp);
- bt_put(upstream_comp);
+
+ if (conn->notified_graph_ports_connected) {
+ /* bt_graph_notify_ports_disconnected() logs details */
+ bt_graph_notify_ports_disconnected(graph, upstream_comp,
+ downstream_comp, upstream_port, downstream_port);
+ }
+
+ bt_object_put_ref(downstream_comp);
+ bt_object_put_ref(upstream_comp);
/*
* Because this connection is ended, finalize (cancel) each
struct bt_port *bt_connection_get_upstream_port(
struct bt_connection *connection)
{
- return connection ? bt_get(connection->upstream_port) : NULL;
+ return connection ? bt_object_get_ref(connection->upstream_port) : NULL;
}
struct bt_port *bt_connection_get_downstream_port(
struct bt_connection *connection)
{
- return connection ? bt_get(connection->downstream_port) : NULL;
+ return connection ? bt_object_get_ref(connection->downstream_port) : NULL;
}
enum bt_connection_status
iterator = NULL;
end:
- bt_put(upstream_component);
- bt_put(iterator);
+ bt_object_put_ref(upstream_component);
+ bt_object_put_ref(iterator);
return status;
}