X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fplugin-system%2Fsink.c;h=e37105b1b60713ae942e1ca8fb2ed3699da3c30e;hb=30d619df191d89101727d0f6d5f4181d2df7653f;hp=81f6cba61cd8a19135a6fd49ce7ba1edf396c805;hpb=4b70dd83c27c589139178db25c9ddb70f24e6192;p=babeltrace.git diff --git a/lib/plugin-system/sink.c b/lib/plugin-system/sink.c index 81f6cba6..e37105b1 100644 --- a/lib/plugin-system/sink.c +++ b/lib/plugin-system/sink.c @@ -29,6 +29,7 @@ #include #include #include +#include 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; +}