do { \
size_t i; \
\
+ if (!_listeners) { \
+ break; \
+ } \
for (i = 0; i < (_listeners)->len; i++) { \
_type *listener = \
&g_array_index((_listeners), _type, i); \
void destroy_message_packet_begin(struct bt_message *msg,
struct bt_graph *graph)
{
- bt_message_packet_beginning_destroy(msg);
+ bt_message_packet_destroy(msg);
}
static
void destroy_message_packet_end(struct bt_message *msg,
struct bt_graph *graph)
{
- bt_message_packet_end_destroy(msg);
+ bt_message_packet_destroy(msg);
}
static
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->is_configured,
- "Graph is already configured: %!+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),
}
end:
+ if (status != BT_GRAPH_STATUS_OK) {
+ graph->config_state = BT_GRAPH_CONFIGURATION_STATE_FAULTY;
+ }
+
bt_object_put_ref(connection);
(void) init_can_consume;
bt_graph_set_can_consume(graph, init_can_consume);
BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
BT_ASSERT_PRE(graph->can_consume,
"Cannot consume graph in its current state: %!+g", graph);
+ BT_ASSERT_PRE(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
+ "Graph is in a faulty state: %!+g", graph);
bt_graph_set_can_consume(graph, false);
- bt_graph_set_is_configured(graph, true);
+ status = bt_graph_configure(graph);
+ if (unlikely(status)) {
+ /* bt_graph_configure() logs errors */
+ goto end;
+ }
+
status = consume_no_check(graph);
bt_graph_set_can_consume(graph, true);
+
+end:
return status;
}
enum bt_graph_status bt_graph_run(struct bt_graph *graph)
{
- enum bt_graph_status status = BT_GRAPH_STATUS_OK;
+ enum bt_graph_status status;
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
BT_ASSERT_PRE(graph->can_consume,
"Cannot consume graph in its current state: %!+g", graph);
+ BT_ASSERT_PRE(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
+ "Graph is in a faulty state: %!+g", graph);
bt_graph_set_can_consume(graph, false);
- bt_graph_set_is_configured(graph, true);
+ status = bt_graph_configure(graph);
+ if (unlikely(status)) {
+ /* bt_graph_configure() logs errors */
+ goto end;
+ }
+
BT_LIB_LOGV("Running graph: %!+g", graph);
do {
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
BT_ASSERT_PRE_NON_NULL(name, "Name");
BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
- BT_ASSERT_PRE(!graph->is_configured,
- "Graph is already configured: %!+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(!component_name_exists(graph, name),
"Duplicate component name: %!+g, name=\"%s\"", graph, name);
BT_ASSERT_PRE(!params || bt_value_is_map(params),
*/
g_ptr_array_add(graph->components, component);
bt_component_set_graph(component, graph);
+ bt_value_freeze(params);
if (init_method) {
BT_LOGD_STR("Calling user's initialization method.");
}
end:
+ if (graph_status != BT_GRAPH_STATUS_OK) {
+ graph->config_state = BT_GRAPH_CONFIGURATION_STATE_FAULTY;
+ }
+
bt_object_put_ref(component);
bt_object_put_ref(new_params);
(void) init_can_consume;