add end of stream notification
[babeltrace.git] / converter / babeltrace.c
index 36db88d11f6cf5d193a50d30213853e5d32ff677..5b381bf6cd1f575f728bdbd820ddb9fca28838d3 100644 (file)
@@ -255,7 +255,7 @@ int main(int argc, char **argv)
                        component_factory, "ctf", BT_COMPONENT_TYPE_SOURCE,
                        "fs");
        if (!source_class) {
-               fprintf(stderr, "Could not find ctf-fs output component class. Aborting...\n");
+               fprintf(stderr, "Could not find ctf-fs source component class. Aborting...\n");
                ret = -1;
                goto end;
        }
@@ -263,7 +263,7 @@ int main(int argc, char **argv)
        sink_class = bt_component_factory_get_component_class(component_factory,
                        "text", BT_COMPONENT_TYPE_SINK, "text");
        if (!sink_class) {
-               fprintf(stderr, "Could not find text output component class. Aborting...\n");
+               fprintf(stderr, "Could not find text sink component class. Aborting...\n");
                ret = -1;
                goto end;
        }
@@ -290,9 +290,29 @@ int main(int argc, char **argv)
        }
 
        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 */
This page took 0.035379 seconds and 4 git commands to generate.