BT_ASSERT(pretty);
switch (bt_notification_get_type(notification)) {
+ case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
+ ret = pretty_print_packet(pretty, notification);
+ break;
case BT_NOTIFICATION_TYPE_EVENT:
ret = pretty_print_event(pretty, notification);
break;
case BT_NOTIFICATION_TYPE_INACTIVITY:
fprintf(stderr, "Inactivity notification\n");
break;
- case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
- case BT_NOTIFICATION_TYPE_PACKET_END:
- case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
- case BT_NOTIFICATION_TYPE_STREAM_END:
- break;
- case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
- case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
- ret = pretty_print_discarded_elements(pretty, notification);
- break;
default:
- fprintf(stderr, "Unhandled notification type\n");
+ break;
}
return ret;
}
BT_HIDDEN
-void pretty_port_connected(
+enum bt_component_status pretty_port_connected(
struct bt_private_component *component,
struct bt_private_port *self_port,
struct bt_port *other_port)
{
+ enum bt_component_status status = BT_COMPONENT_STATUS_OK;
enum bt_connection_status conn_status;
struct bt_private_connection *connection;
struct pretty_component *pretty;
- static const enum bt_notification_type notif_types[] = {
- BT_NOTIFICATION_TYPE_EVENT,
- BT_NOTIFICATION_TYPE_DISCARDED_PACKETS,
- BT_NOTIFICATION_TYPE_DISCARDED_EVENTS,
- BT_NOTIFICATION_TYPE_SENTINEL,
- };
pretty = bt_private_component_get_user_data(component);
BT_ASSERT(pretty);
connection = bt_private_port_get_private_connection(self_port);
BT_ASSERT(connection);
conn_status = bt_private_connection_create_notification_iterator(
- connection, notif_types, &pretty->input_iterator);
+ connection, &pretty->input_iterator);
if (conn_status != BT_CONNECTION_STATUS_OK) {
- pretty->error = true;
+ status = BT_COMPONENT_STATUS_ERROR;
}
bt_put(connection);
+ return status;
}
BT_HIDDEN
enum bt_component_status pretty_consume(struct bt_private_component *component)
{
enum bt_component_status ret;
- struct bt_notification *notification = NULL;
+ bt_notification_array notifs;
struct bt_notification_iterator *it;
struct pretty_component *pretty =
bt_private_component_get_user_data(component);
enum bt_notification_iterator_status it_ret;
-
- if (unlikely(pretty->error)) {
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
- }
+ uint64_t count = 0;
+ uint64_t i = 0;
it = pretty->input_iterator;
- it_ret = bt_notification_iterator_next(it);
+ it_ret = bt_private_connection_notification_iterator_next(it, ¬ifs,
+ &count);
switch (it_ret) {
case BT_NOTIFICATION_ITERATOR_STATUS_END:
goto end;
}
- notification = bt_notification_iterator_get_notification(it);
- BT_ASSERT(notification);
- ret = handle_notification(pretty, notification);
+ BT_ASSERT(it_ret == BT_NOTIFICATION_ITERATOR_STATUS_OK);
+
+ for (i = 0; i < count; i++) {
+ ret = handle_notification(pretty, notifs[i]);
+ if (ret) {
+ goto end;
+ }
+
+ bt_put(notifs[i]);
+ }
end:
- bt_put(notification);
+ for (; i < count; i++) {
+ bt_put(notifs[i]);
+ }
+
return ret;
}
struct pretty_component *pretty = data;
struct bt_value *plugin_opt_map = pretty->plugin_opt_map;
- if (!bt_value_map_get(plugin_opt_map, key)) {
+ if (!bt_value_map_has_key(plugin_opt_map, key)) {
fprintf(pretty->err,
"[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
}
enum bt_value_status status;
const char *str;
- value = bt_value_map_get(params, key);
+ value = bt_value_map_borrow(params, key);
if (!value) {
goto end;
}
}
*option = g_strdup(str);
end:
- bt_put(value);
return ret;
}
enum bt_value_status status;
bt_bool bool_val;
- value = bt_value_map_get(params, key);
+ value = bt_value_map_borrow(params, key);
if (!value) {
goto end;
}
if (found) {
*found = true;
}
+
end:
- bt_put(value);
return ret;
}
struct bt_value *color_value;
const char *color;
- color_value = bt_value_map_get(params, "color");
+ color_value = bt_value_map_borrow(params, "color");
if (!color_value) {
goto end;
}
warn_wrong_color_param(pretty);
}
}
-
- bt_put(color_value);
}
ret = apply_one_string("path", params, &pretty->options.output_path);