X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=converter%2Fbabeltrace.c;h=e563c0a4fd6b18c98d101ba5ed1d989f02739a12;hb=78586d8a10bfb11d34d187697ae15e9255c6ddf4;hp=cd7bd7c48b3cd0746ce03cbb9b36435c55580cf5;hpb=56a1ccedd4a58b6c87d1bbd94e22094ad5ac1a98;p=babeltrace.git diff --git a/converter/babeltrace.c b/converter/babeltrace.c index cd7bd7c4..e563c0a4 100644 --- a/converter/babeltrace.c +++ b/converter/babeltrace.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -201,6 +202,7 @@ int main(int argc, char **argv) struct bt_component_class *source_class = NULL, *sink_class = NULL; struct bt_component *source = NULL, *sink = NULL; struct bt_value *source_params = NULL, *sink_params = NULL; + struct bt_notification_iterator *it = NULL; ret = parse_options(argc, argv); if (ret < 0) { @@ -280,6 +282,39 @@ int main(int argc, char **argv) goto end; } + it = bt_component_source_create_iterator(source); + if (!it) { + fprintf(stderr, "Failed to instantiate source iterator. Aborting...\n"); + ret = -1; + goto end; + } + + do { + enum bt_component_status sink_status; + struct bt_notification *notification = + bt_notification_iterator_get_notification(it); + + if (!notification) { + /* + * Should never happen in final code except after next + * has returned BT_NOTIFICATION_ITERATOR_STATUS_END. + * + * Right now it happens at the first event since the + * iterator is not completely initialized and we don't + * have a notification "heap" in place. + */ + continue; + } + + sink_status = bt_component_sink_handle_notification(sink, + notification); + BT_PUT(notification); + if (sink_status != BT_COMPONENT_STATUS_OK) { + fprintf(stderr, "Sink component returned an error, aborting...\n"); + break; + } + } while (bt_notification_iterator_next(it) == + BT_NOTIFICATION_ITERATOR_STATUS_OK); /* teardown and exit */ end: BT_PUT(component_factory); @@ -289,5 +324,6 @@ end: BT_PUT(sink); BT_PUT(source_params); BT_PUT(sink_params); + BT_PUT(it); return ret ? 1 : 0; }