Add built-in colander sink component class
You can use this new built-in sink component class to create a component
which passes the consumed notification to the user through a pointer
passed as the initialization method data:
struct bt_notification *notif = NULL;
struct bt_component_class *colander_cc =
bt_component_class_sink_colander_get();
struct bt_component *colander_comp;
ret = bt_graph_add_component_with_init_method_data(graph,
colander_cc, "colander", NULL, ¬if, &colander_comp);
...
for (;;) {
ret = bt_graph_consume(graph);
if (ret != BT_GRAPH_STATUS_OK) {
...
}
/* Do something with notif */
BT_PUT(notif);
}
Everytime you call bt_graph_consume() and this function is successful,
your notification pointer contains a reference to the consumed
notification. You need to release this reference with bt_put(), as the
colander component won't do it. This is why you should not use
bt_graph_run() with a colander component because notifications will
leak.
bt_component_class_sink_colander_get() lazily creates the component
class the first time it is called and the uses this same reference for
future calls. The source file's destructor releases the global reference
when the library is destroyed.
The component class is built-in so that you do not need any installed
plugins to use this utility. Since it's not part of a plugin, you cannot
use it with the CLI, but this is okay because it needs custom
initialization method data anyway.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.027744 seconds and 4 git commands to generate.