Strip babeltrace.c
[babeltrace.git] / plugins / sink.c
index 911b5e84060088eadd45ddcc89df00b2ff0d0282..81f6cba61cd8a19135a6fd49ce7ba1edf396c805 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * sink.c
  *
- * Babeltrace Source Component
+ * Babeltrace Sink Component
  *
  * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
 static
 void bt_component_sink_destroy(struct bt_component *component)
 {
-       struct bt_component_sink *sink;
-
-       if (!component) {
-               return;
-       }
+       return;
+}
 
-       sink = container_of(component, struct bt_component_sink, parent);
-       g_free(sink);
+BT_HIDDEN
+enum bt_component_status bt_component_sink_validate(
+               struct bt_component *component)
+{
+       return BT_COMPONENT_STATUS_OK;
 }
 
-struct bt_component *bt_component_sink_create(const char *name,
-               void *private_data, bt_component_destroy_cb destroy_func,
-               bt_component_sink_handle_notification_cb notification_cb)
+BT_HIDDEN
+struct bt_component *bt_component_sink_create(
+               struct bt_component_class *class, struct bt_value *params)
 {
        struct bt_component_sink *sink = NULL;
        enum bt_component_status ret;
 
-       if (!notification_cb) {
-               goto end;
-       }
-
        sink = g_new0(struct bt_component_sink, 1);
        if (!sink) {
                goto end;
        }
 
-       ret = bt_component_init(&sink->parent, name, private_data,
-                               destroy_func, BT_COMPONENT_TYPE_SINK,
-                               bt_component_sink_destroy);
+       ret = bt_component_init(&sink->parent, bt_component_sink_destroy);
        if (ret != BT_COMPONENT_STATUS_OK) {
-               g_free(sink);
-               sink = NULL;
+               BT_PUT(sink);
                goto end;
        }
-
-       sink->handle_notification = notification_cb;
 end:
        return sink ? &sink->parent : NULL;
 }
+
+enum bt_component_status bt_component_sink_handle_notification(
+               struct bt_component *component,
+               struct bt_notification *notification)
+{
+       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       struct bt_component_sink *sink = NULL;
+
+       if (!component || !notification) {
+               ret = BT_COMPONENT_STATUS_INVAL;
+               goto end;
+       }
+
+       if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+               ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+               goto end;
+       }
+
+       sink = container_of(component, struct bt_component_sink, parent);
+       assert(sink->handle_notification);
+       ret = sink->handle_notification(component, notification);
+end:
+       return ret;
+}
This page took 0.024255 seconds and 4 git commands to generate.