Remove default port API
[babeltrace.git] / plugins / writer / writer.c
index 5dbd5d596e54a8aa122a6f895f7d49168d6cd427..118210ab2bfe42e771a40dbde7d3fc445105af0e 100644 (file)
@@ -185,12 +185,11 @@ end:
 }
 
 static
-enum bt_component_status writer_component_accept_port_connection(
+void writer_component_port_connected(
                struct bt_private_component *component,
                struct bt_private_port *self_port,
                struct bt_port *other_port)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
        struct bt_private_connection *connection;
        struct writer_component *writer;
 
@@ -203,10 +202,10 @@ enum bt_component_status writer_component_accept_port_connection(
                bt_private_connection_create_notification_iterator(connection);
 
        if (!writer->input_iterator) {
-               ret = BT_COMPONENT_STATUS_ERROR;
+               writer->error = true;
        }
+
        bt_put(connection);
-       return ret;
 }
 
 static
@@ -221,6 +220,11 @@ enum bt_component_status run(struct bt_private_component *component)
        it = writer_component->input_iterator;
        assert(it);
 
+       if (unlikely(writer_component->error)) {
+               ret = BT_COMPONENT_STATUS_ERROR;
+               goto end;
+       }
+
        if (likely(writer_component->processed_first_event)) {
                enum bt_notification_iterator_status it_ret;
 
@@ -261,12 +265,22 @@ enum bt_component_status writer_component_init(
        struct writer_component *writer_component = create_writer_component();
        struct bt_value *value = NULL;
        const char *path;
+       void *priv_port;
 
        if (!writer_component) {
                ret = BT_COMPONENT_STATUS_NOMEM;
                goto end;
        }
 
+       priv_port = bt_private_component_sink_add_input_private_port(component,
+               "in", NULL);
+       if (!priv_port) {
+               ret = BT_COMPONENT_STATUS_NOMEM;
+               goto end;
+       }
+
+       bt_put(priv_port);
+
        value = bt_value_map_get(params, "path");
        if (!value || bt_value_is_null(value) || !bt_value_is_string(value)) {
                fprintf(writer_component->err,
@@ -308,7 +322,7 @@ BT_PLUGIN_AUTHOR("Jérémie Galarneau");
 BT_PLUGIN_LICENSE("MIT");
 BT_PLUGIN_SINK_COMPONENT_CLASS(writer, run);
 BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(writer, writer_component_init);
-BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD(writer,
-               writer_component_accept_port_connection);
+BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD(writer,
+               writer_component_port_connected);
 BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(writer, finalize_writer_component);
 BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(writer, "Formats CTF-IR to CTF.");
This page took 0.026192 seconds and 4 git commands to generate.