X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fgraph.c;h=32af1ef898585d4c240f7e505c79de01970226be;hb=98b15851a941e7342b8bb19e265cdc3a40fabfb8;hp=ebcd9db8954ec08a26cfeaa2f922b843b59916aa;hpb=9628043c93e05c65bc5e334c1d9a0e1bf2cb3a3c;p=babeltrace.git diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index ebcd9db8..32af1ef8 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -58,8 +58,8 @@ typedef enum bt_graph_listener_func_status (*ports_connected_func_t)(const void *, const void *, const void *, const void *, void *); -typedef enum bt_component_class_init_method_status -(*comp_init_method_t)(const void *, const void *, void *); +typedef enum bt_component_class_initialize_method_status +(*comp_init_method_t)(const void *, void *, const void *, void *); struct bt_graph_listener { bt_graph_listener_removed_func removed; @@ -262,11 +262,15 @@ void notify_message_graph_is_destroyed(struct bt_message *msg) bt_message_unlink_graph(msg); } -struct bt_graph *bt_graph_create(void) +struct bt_graph *bt_graph_create(uint64_t mip_version) { struct bt_graph *graph; int ret; + BT_ASSERT_PRE(mip_version <= bt_get_maximal_mip_version(), + "Unknown MIP version: mip-version=%" PRIu64 ", " + "max-mip-version=%" PRIu64, + mip_version, bt_get_maximal_mip_version()); BT_LOGI_STR("Creating graph object."); graph = g_new0(struct bt_graph, 1); if (!graph) { @@ -275,6 +279,7 @@ struct bt_graph *bt_graph_create(void) } bt_object_init_shared(&graph->base, destroy_graph); + graph->mip_version = mip_version; graph->connections = g_ptr_array_new_with_free_func( (GDestroyNotify) bt_object_try_spec_release); if (!graph->connections) { @@ -298,7 +303,6 @@ struct bt_graph *bt_graph_create(void) graph->listeners.source_output_port_added); if (!graph->listeners.source_output_port_added) { - ret = -1; goto error; } @@ -306,7 +310,6 @@ struct bt_graph *bt_graph_create(void) graph->listeners.filter_output_port_added); if (!graph->listeners.filter_output_port_added) { - ret = -1; goto error; } @@ -314,7 +317,6 @@ struct bt_graph *bt_graph_create(void) graph->listeners.filter_input_port_added); if (!graph->listeners.filter_input_port_added) { - ret = -1; goto error; } @@ -322,7 +324,6 @@ struct bt_graph *bt_graph_create(void) graph->listeners.sink_input_port_added); if (!graph->listeners.sink_input_port_added) { - ret = -1; goto error; } @@ -330,7 +331,6 @@ struct bt_graph *bt_graph_create(void) graph->listeners.source_filter_ports_connected); if (!graph->listeners.source_filter_ports_connected) { - ret = -1; goto error; } @@ -338,7 +338,6 @@ struct bt_graph *bt_graph_create(void) graph->listeners.source_sink_ports_connected); if (!graph->listeners.source_sink_ports_connected) { - ret = -1; goto error; } @@ -346,7 +345,6 @@ struct bt_graph *bt_graph_create(void) graph->listeners.filter_filter_ports_connected); if (!graph->listeners.filter_filter_ports_connected) { - ret = -1; goto error; } @@ -354,12 +352,11 @@ struct bt_graph *bt_graph_create(void) graph->listeners.filter_sink_ports_connected); if (!graph->listeners.filter_sink_ports_connected) { - ret = -1; goto error; } graph->interrupters = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_object_put_no_null_check); + (GDestroyNotify) bt_object_put_ref_no_null_check); if (!graph->interrupters) { BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GPtrArray."); goto error; @@ -576,9 +573,9 @@ int consume_graph_sink(struct bt_component_sink *comp) enum bt_component_class_sink_consume_method_status consume_status; struct bt_component_class_sink *sink_class = NULL; - BT_ASSERT(comp); + BT_ASSERT_DBG(comp); sink_class = (void *) comp->parent.class; - BT_ASSERT(sink_class->methods.consume); + BT_ASSERT_DBG(sink_class->methods.consume); BT_LIB_LOGD("Calling user's consume method: %!+c", comp); consume_status = sink_class->methods.consume((void *) comp); BT_LOGD("User method returned: status=%s", @@ -651,7 +648,7 @@ int bt_graph_consume_sink_no_check(struct bt_graph *graph, int index; BT_LIB_LOGD("Making specific sink consume: %![comp-]+c", sink); - BT_ASSERT(bt_component_borrow_graph((void *) sink) == graph); + BT_ASSERT_DBG(bt_component_borrow_graph((void *) sink) == graph); if (g_queue_is_empty(graph->sinks_to_consume)) { BT_LOGD_STR("Graph's sink queue is empty: end of graph."); @@ -668,7 +665,7 @@ int bt_graph_consume_sink_no_check(struct bt_graph *graph, } sink_node = g_queue_pop_nth_link(graph->sinks_to_consume, index); - BT_ASSERT(sink_node); + BT_ASSERT_DBG(sink_node); status = consume_sink_node(graph, sink_node); end: @@ -1269,7 +1266,7 @@ int add_component_with_init_method_data( const struct bt_component **user_component) { int status = BT_FUNC_STATUS_OK; - enum bt_component_class_init_method_status init_status; + enum bt_component_class_initialize_method_status init_status; struct bt_component *component = NULL; int ret; bool init_can_consume; @@ -1325,8 +1322,12 @@ int add_component_with_init_method_data( bt_value_freeze(params); if (init_method) { + /* + * There is no use for config objects right now, so just pass + * NULL. + */ BT_LOGD_STR("Calling user's initialization method."); - init_status = init_method(component, params, init_method_data); + init_status = init_method(component, NULL, params, init_method_data); BT_LOGD("User method returned: status=%s", bt_common_func_status_string(init_status)); if (init_status != BT_FUNC_STATUS_OK) { @@ -1393,7 +1394,7 @@ end: } enum bt_graph_add_component_status -bt_graph_add_source_component_with_init_method_data( +bt_graph_add_source_component_with_initialize_method_data( struct bt_graph *graph, const struct bt_component_class_source *comp_cls, const char *name, const struct bt_value *params, @@ -1413,12 +1414,12 @@ enum bt_graph_add_component_status bt_graph_add_source_component( enum bt_logging_level log_level, const struct bt_component_source **component) { - return bt_graph_add_source_component_with_init_method_data( + return bt_graph_add_source_component_with_initialize_method_data( graph, comp_cls, name, params, NULL, log_level, component); } enum bt_graph_add_component_status -bt_graph_add_filter_component_with_init_method_data( +bt_graph_add_filter_component_with_initialize_method_data( struct bt_graph *graph, const struct bt_component_class_filter *comp_cls, const char *name, const struct bt_value *params, @@ -1438,12 +1439,12 @@ enum bt_graph_add_component_status bt_graph_add_filter_component( enum bt_logging_level log_level, const struct bt_component_filter **component) { - return bt_graph_add_filter_component_with_init_method_data( + return bt_graph_add_filter_component_with_initialize_method_data( graph, comp_cls, name, params, NULL, log_level, component); } enum bt_graph_add_component_status -bt_graph_add_sink_component_with_init_method_data( +bt_graph_add_sink_component_with_initialize_method_data( struct bt_graph *graph, const struct bt_component_class_sink *comp_cls, const char *name, const struct bt_value *params, @@ -1463,13 +1464,13 @@ enum bt_graph_add_component_status bt_graph_add_sink_component( enum bt_logging_level log_level, const struct bt_component_sink **component) { - return bt_graph_add_sink_component_with_init_method_data( + return bt_graph_add_sink_component_with_initialize_method_data( graph, comp_cls, name, params, NULL, log_level, component); } enum bt_graph_add_component_status bt_graph_add_simple_sink_component(struct bt_graph *graph, const char *name, - bt_graph_simple_sink_component_init_func init_func, + bt_graph_simple_sink_component_initialize_func init_func, bt_graph_simple_sink_component_consume_func consume_func, bt_graph_simple_sink_component_finalize_func finalize_func, void *user_data, const bt_component_sink **component) @@ -1497,7 +1498,7 @@ bt_graph_add_simple_sink_component(struct bt_graph *graph, const char *name, goto end; } - status = bt_graph_add_sink_component_with_init_method_data(graph, + status = bt_graph_add_sink_component_with_initialize_method_data(graph, comp_cls, name, NULL, &init_method_data, BT_LOGGING_LEVEL_NONE, component); @@ -1603,7 +1604,7 @@ void bt_graph_add_message(struct bt_graph *graph, BT_HIDDEN bool bt_graph_is_interrupted(const struct bt_graph *graph) { - BT_ASSERT(graph); + BT_ASSERT_DBG(graph); return bt_interrupter_array_any_is_set(graph->interrupters); } @@ -1613,7 +1614,7 @@ enum bt_graph_add_interrupter_status bt_graph_add_interrupter( BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(intr, "Interrupter"); g_ptr_array_add(graph->interrupters, (void *) intr); - bt_object_get_no_null_check(intr); + bt_object_get_ref_no_null_check(intr); BT_LIB_LOGD("Added interrupter to graph: %![graph-]+g, %![intr-]+z", graph, intr); return BT_FUNC_STATUS_OK;