Add bt_component_sink_register_notification_type
[babeltrace.git] / lib / plugin-system / sink.c
index 81f6cba61cd8a19135a6fd49ce7ba1edf396c805..e37105b1b60713ae942e1ca8fb2ed3699da3c30e 100644 (file)
@@ -29,6 +29,7 @@
 #include <babeltrace/compiler.h>
 #include <babeltrace/plugin/sink-internal.h>
 #include <babeltrace/plugin/component-internal.h>
+#include <babeltrace/plugin/notification/notification.h>
 
 static
 void bt_component_sink_destroy(struct bt_component *component)
@@ -72,7 +73,7 @@ enum bt_component_status bt_component_sink_handle_notification(
        struct bt_component_sink *sink = NULL;
 
        if (!component || !notification) {
-               ret = BT_COMPONENT_STATUS_INVAL;
+               ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
 
@@ -87,3 +88,35 @@ enum bt_component_status bt_component_sink_handle_notification(
 end:
        return ret;
 }
+
+enum bt_component_status bt_component_sink_register_notification_type(
+               struct bt_component *component, enum bt_notification_type type)
+{
+       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       struct bt_component_sink *sink = NULL;
+
+       if (!component) {
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+
+       if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+               ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+               goto end;
+       }
+
+       if (type <= BT_NOTIFICATION_TYPE_UNKNOWN ||
+               type >= BT_NOTIFICATION_TYPE_NR) {
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+       sink = container_of(component, struct bt_component_sink, parent);
+       if (type == BT_NOTIFICATION_TYPE_ALL) {
+               sink->registered_notifications_mask = ~(notification_mask_t) 0;
+       } else {
+               sink->registered_notifications_mask |=
+                       (notification_mask_t) 1 << type;
+       }
+end:
+       return ret;
+}
This page took 0.025205 seconds and 4 git commands to generate.