X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fiterator.c;h=0cd93172d8de9cfd1b2fc64783e30a8ff79a93d7;hb=f6ccaed94e575af57fe6bf38154771bee4871a2a;hp=1979c69a8791ee8fa194b93b61f559a511aafac8;hpb=8ed535b5ed7341916a1dd486b87bdc6e94ed1b81;p=babeltrace.git diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 1979c69a..0cd93172 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -57,18 +57,19 @@ #include #include #include +#include #include #include #include struct discarded_elements_state { - struct bt_ctf_clock_value *cur_begin; + struct bt_clock_value *cur_begin; uint64_t cur_count; }; struct stream_state { - struct bt_ctf_stream *stream; /* owned by this */ - struct bt_ctf_packet *cur_packet; /* owned by this */ + struct bt_stream *stream; /* owned by this */ + struct bt_packet *cur_packet; /* owned by this */ struct discarded_elements_state discarded_packets_state; struct discarded_elements_state discarded_events_state; bt_bool is_ended; @@ -94,14 +95,14 @@ struct action { /* ACTION_TYPE_MAP_PORT_TO_COMP_IN_STREAM */ struct { - struct bt_ctf_stream *stream; /* owned by this */ + struct bt_stream *stream; /* owned by this */ struct bt_component *component; /* owned by this */ struct bt_port *port; /* owned by this */ } map_port_to_comp_in_stream; /* ACTION_TYPE_ADD_STREAM_STATE */ struct { - struct bt_ctf_stream *stream; /* owned by this */ + struct bt_stream *stream; /* owned by this */ struct stream_state *stream_state; /* owned by this */ } add_stream_state; @@ -113,21 +114,21 @@ struct action { /* ACTION_TYPE_SET_STREAM_STATE_CUR_PACKET */ struct { struct stream_state *stream_state; /* weak */ - struct bt_ctf_packet *packet; /* owned by this */ + struct bt_packet *packet; /* owned by this */ } set_stream_state_cur_packet; /* ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_PACKETS */ /* ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_EVENTS */ struct { struct stream_state *stream_state; /* weak */ - struct bt_ctf_clock_value *cur_begin; /* owned by this */ + struct bt_clock_value *cur_begin; /* owned by this */ uint64_t cur_count; } update_stream_state_discarded_elements; } payload; }; static -void stream_destroy_listener(struct bt_ctf_stream *stream, void *data) +void stream_destroy_listener(struct bt_stream *stream, void *data) { struct bt_notification_iterator_private_connection *iterator = data; @@ -155,7 +156,7 @@ void destroy_stream_state(struct stream_state *stream_state) static void destroy_action(struct action *action) { - assert(action); + BT_ASSERT(action); switch (action->type) { case ACTION_TYPE_PUSH_NOTIF: @@ -257,7 +258,7 @@ void apply_actions(struct bt_notification_iterator_private_connection *iterator) action->payload.push_notif.notif = NULL; break; case ACTION_TYPE_MAP_PORT_TO_COMP_IN_STREAM: - bt_ctf_stream_map_component_to_port( + bt_stream_map_component_to_port( action->payload.map_port_to_comp_in_stream.stream, action->payload.map_port_to_comp_in_stream.component, action->payload.map_port_to_comp_in_stream.port); @@ -287,7 +288,7 @@ void apply_actions(struct bt_notification_iterator_private_connection *iterator) * could be reused for another stream, and they * must have different states. */ - bt_ctf_stream_add_destroy_listener( + bt_stream_add_destroy_listener( action->payload.set_stream_state_is_ended.stream_state->stream, stream_destroy_listener, iterator); action->payload.set_stream_state_is_ended.stream_state->is_ended = BT_TRUE; @@ -325,7 +326,7 @@ void apply_actions(struct bt_notification_iterator_private_connection *iterator) } static -struct stream_state *create_stream_state(struct bt_ctf_stream *stream) +struct stream_state *create_stream_state(struct bt_stream *stream) { struct stream_state *stream_state = g_new0(struct stream_state, 1); @@ -354,7 +355,7 @@ struct stream_state *create_stream_state(struct bt_ctf_stream *stream) stream_state->stream = bt_get(stream); BT_LOGV("Created stream state: stream-addr=%p, stream-name=\"%s\", " "stream-state-addr=%p", - stream, bt_ctf_stream_get_name(stream), stream_state); + stream, bt_stream_get_name(stream), stream_state); end: return stream_state; @@ -376,7 +377,7 @@ void bt_private_connection_notification_iterator_destroy(struct bt_object *obj) { struct bt_notification_iterator_private_connection *iterator; - assert(obj); + BT_ASSERT(obj); /* * The notification iterator's reference count is 0 if we're @@ -419,10 +420,10 @@ void bt_private_connection_notification_iterator_destroy(struct bt_object *obj) g_hash_table_iter_init(&ht_iter, iterator->stream_states); while (g_hash_table_iter_next(&ht_iter, &stream_gptr, &stream_state_gptr)) { - assert(stream_gptr); + BT_ASSERT(stream_gptr); BT_LOGD_STR("Removing stream's destroy listener for notification iterator."); - bt_ctf_stream_remove_destroy_listener( + bt_stream_remove_destroy_listener( (void *) stream_gptr, stream_destroy_listener, iterator); } @@ -454,7 +455,7 @@ void bt_private_connection_notification_iterator_finalize( bt_component_class_notification_iterator_finalize_method finalize_method = NULL; - assert(iterator); + BT_ASSERT(iterator); switch (iterator->state) { case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED: @@ -484,7 +485,7 @@ void bt_private_connection_notification_iterator_finalize( iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED; } - assert(iterator->upstream_component); + BT_ASSERT(iterator->upstream_component); comp_class = iterator->upstream_component->class; /* Call user-defined destroy method */ @@ -527,7 +528,7 @@ void bt_private_connection_notification_iterator_set_connection( struct bt_notification_iterator_private_connection *iterator, struct bt_connection *connection) { - assert(iterator); + BT_ASSERT(iterator); iterator->connection = connection; BT_LOGV("Set notification iterator's connection: " "iter-addr=%p, conn-addr=%p", iterator, connection); @@ -541,7 +542,7 @@ int create_subscription_mask_from_notification_types( const enum bt_notification_type *notif_type; int ret = 0; - assert(notif_types); + BT_ASSERT(notif_types); iterator->subscription_mask = 0; for (notif_type = notif_types; @@ -619,11 +620,11 @@ enum bt_connection_status bt_private_connection_notification_iterator_create( enum bt_component_class_type type; struct bt_notification_iterator_private_connection *iterator = NULL; - assert(upstream_comp); - assert(upstream_port); - assert(notification_types); - assert(bt_port_is_connected(upstream_port)); - assert(user_iterator); + BT_ASSERT(upstream_comp); + BT_ASSERT(upstream_port); + BT_ASSERT(notification_types); + BT_ASSERT(bt_port_is_connected(upstream_port)); + BT_ASSERT(user_iterator); BT_LOGD("Creating notification iterator on private connection: " "upstream-comp-addr=%p, upstream-comp-name=\"%s\", " "upstream-port-addr=%p, upstream-port-name=\"%s\", " @@ -632,7 +633,7 @@ enum bt_connection_status bt_private_connection_notification_iterator_create( upstream_port, bt_port_get_name(upstream_port), connection); type = bt_component_get_class_type(upstream_comp); - assert(type == BT_COMPONENT_CLASS_TYPE_SOURCE || + BT_ASSERT(type == BT_COMPONENT_CLASS_TYPE_SOURCE || type == BT_COMPONENT_CLASS_TYPE_FILTER); iterator = g_new0(struct bt_notification_iterator_private_connection, 1); if (!iterator) { @@ -699,7 +700,7 @@ void *bt_private_connection_private_notification_iterator_get_user_data( struct bt_private_connection_private_notification_iterator *private_iterator) { struct bt_notification_iterator_private_connection *iterator = - bt_private_connection_notification_iterator_from_private(private_iterator); + bt_private_connection_notification_iterator_borrow_from_private(private_iterator); return iterator ? iterator->user_data : NULL; } @@ -712,7 +713,7 @@ bt_private_connection_private_notification_iterator_set_user_data( enum bt_notification_iterator_status ret = BT_NOTIFICATION_ITERATOR_STATUS_OK; struct bt_notification_iterator_private_connection *iterator = - bt_private_connection_notification_iterator_from_private(private_iterator); + bt_private_connection_notification_iterator_borrow_from_private(private_iterator); if (!iterator) { BT_LOGW_STR("Invalid parameter: notification iterator is NULL."); @@ -788,16 +789,16 @@ static bt_bool validate_notification( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *notif, - struct bt_ctf_stream *notif_stream, - struct bt_ctf_packet *notif_packet) + struct bt_stream *notif_stream, + struct bt_packet *notif_packet) { bt_bool is_valid = BT_TRUE; struct stream_state *stream_state; struct bt_port *stream_comp_cur_port; - assert(notif_stream); + BT_ASSERT(notif_stream); stream_comp_cur_port = - bt_ctf_stream_port_for_component(notif_stream, + bt_stream_port_for_component(notif_stream, iterator->upstream_component); if (!stream_comp_cur_port) { /* @@ -832,7 +833,7 @@ bt_bool validate_notification( "iter-upstream-port-addr=%p, " "iter-upstream-port-name=%s", notif_stream, - bt_ctf_stream_get_name(notif_stream), + bt_stream_get_name(notif_stream), stream_comp_cur_port, bt_port_get_name(stream_comp_cur_port), iterator->upstream_port, @@ -850,7 +851,7 @@ bt_bool validate_notification( "stream-addr=%p, stream-name=\"%s\", " "stream-state-addr=%p", notif_stream, - bt_ctf_stream_get_name(notif_stream), stream_state); + bt_stream_get_name(notif_stream), stream_state); if (stream_state->is_ended) { /* @@ -864,7 +865,7 @@ bt_bool validate_notification( BT_LOGW("Stream is already ended: " "stream-addr=%p, stream-name=\"%s\"", notif_stream, - bt_ctf_stream_get_name(notif_stream)); + bt_stream_get_name(notif_stream)); is_valid = BT_FALSE; goto end; } @@ -879,7 +880,7 @@ bt_bool validate_notification( BT_LOGW("Duplicate stream beginning notification: " "stream-addr=%p, stream-name=\"%s\"", notif_stream, - bt_ctf_stream_get_name(notif_stream)); + bt_stream_get_name(notif_stream)); is_valid = BT_FALSE; goto end; case BT_NOTIFICATION_TYPE_PACKET_BEGIN: @@ -889,7 +890,7 @@ bt_bool validate_notification( "stream-addr=%p, stream-name=\"%s\", " "packet-addr=%p", notif_stream, - bt_ctf_stream_get_name(notif_stream), + bt_stream_get_name(notif_stream), notif_packet); is_valid = BT_FALSE; goto end; @@ -925,7 +926,7 @@ void add_action_push_notif( .type = ACTION_TYPE_PUSH_NOTIF, }; - assert(notif); + BT_ASSERT(notif); if (!is_subscribed_to_notification_type(iterator, notif->type)) { return; @@ -939,7 +940,7 @@ void add_action_push_notif( static int add_action_push_notif_stream_begin( struct bt_notification_iterator_private_connection *iterator, - struct bt_ctf_stream *stream) + struct bt_stream *stream) { int ret = 0; struct bt_notification *stream_begin_notif = NULL; @@ -952,7 +953,7 @@ int add_action_push_notif_stream_begin( goto end; } - assert(stream); + BT_ASSERT(stream); stream_begin_notif = bt_notification_stream_begin_create(stream); if (!stream_begin_notif) { BT_LOGE_STR("Cannot create stream beginning notification."); @@ -962,7 +963,7 @@ int add_action_push_notif_stream_begin( add_action_push_notif(iterator, stream_begin_notif); BT_LOGV("Added \"push stream beginning notification\" action: " "stream-addr=%p, stream-name=\"%s\"", - stream, bt_ctf_stream_get_name(stream)); + stream, bt_stream_get_name(stream)); goto end; error: @@ -976,7 +977,7 @@ end: static int add_action_push_notif_stream_end( struct bt_notification_iterator_private_connection *iterator, - struct bt_ctf_stream *stream) + struct bt_stream *stream) { int ret = 0; struct bt_notification *stream_end_notif = NULL; @@ -989,7 +990,7 @@ int add_action_push_notif_stream_end( goto end; } - assert(stream); + BT_ASSERT(stream); stream_end_notif = bt_notification_stream_end_create(stream); if (!stream_end_notif) { BT_LOGE_STR("Cannot create stream end notification."); @@ -999,7 +1000,7 @@ int add_action_push_notif_stream_end( add_action_push_notif(iterator, stream_end_notif); BT_LOGV("Added \"push stream end notification\" action: " "stream-addr=%p, stream-name=\"%s\"", - stream, bt_ctf_stream_get_name(stream)); + stream, bt_stream_get_name(stream)); goto end; error: @@ -1013,7 +1014,7 @@ end: static int add_action_push_notif_packet_begin( struct bt_notification_iterator_private_connection *iterator, - struct bt_ctf_packet *packet) + struct bt_packet *packet) { int ret = 0; struct bt_notification *packet_begin_notif = NULL; @@ -1026,7 +1027,7 @@ int add_action_push_notif_packet_begin( goto end; } - assert(packet); + BT_ASSERT(packet); packet_begin_notif = bt_notification_packet_begin_create(packet); if (!packet_begin_notif) { BT_LOGE_STR("Cannot create packet beginning notification."); @@ -1049,7 +1050,7 @@ end: static int add_action_push_notif_packet_end( struct bt_notification_iterator_private_connection *iterator, - struct bt_ctf_packet *packet) + struct bt_packet *packet) { int ret = 0; struct bt_notification *packet_end_notif = NULL; @@ -1062,7 +1063,7 @@ int add_action_push_notif_packet_end( goto end; } - assert(packet); + BT_ASSERT(packet); packet_end_notif = bt_notification_packet_end_create(packet); if (!packet_end_notif) { BT_LOGE_STR("Cannot create packet end notification."); @@ -1094,7 +1095,7 @@ void add_action_set_stream_state_is_ended( }, }; - assert(stream_state); + BT_ASSERT(stream_state); add_action(iterator, &action); BT_LOGV("Added \"set stream state's ended\" action: " "stream-state-addr=%p", stream_state); @@ -1104,7 +1105,7 @@ static void add_action_set_stream_state_cur_packet( struct bt_notification_iterator_private_connection *iterator, struct stream_state *stream_state, - struct bt_ctf_packet *packet) + struct bt_packet *packet) { struct action action = { .type = ACTION_TYPE_SET_STREAM_STATE_CUR_PACKET, @@ -1114,7 +1115,7 @@ void add_action_set_stream_state_cur_packet( }, }; - assert(stream_state); + BT_ASSERT(stream_state); add_action(iterator, &action); BT_LOGV("Added \"set stream state's current packet\" action: " "stream-state-addr=%p, packet-addr=%p", @@ -1126,7 +1127,7 @@ void add_action_update_stream_state_discarded_elements( struct bt_notification_iterator_private_connection *iterator, enum action_type type, struct stream_state *stream_state, - struct bt_ctf_clock_value *cur_begin, + struct bt_clock_value *cur_begin, uint64_t cur_count) { struct action action = { @@ -1138,8 +1139,8 @@ void add_action_update_stream_state_discarded_elements( }, }; - assert(stream_state); - assert(type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_PACKETS || + BT_ASSERT(stream_state); + BT_ASSERT(type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_PACKETS || type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_EVENTS); add_action(iterator, &action); if (type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_PACKETS) { @@ -1157,7 +1158,7 @@ static int ensure_stream_state_exists( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *stream_begin_notif, - struct bt_ctf_stream *notif_stream, + struct bt_stream *notif_stream, struct stream_state **_stream_state) { int ret = 0; @@ -1220,32 +1221,32 @@ end: } static -struct bt_ctf_field *get_struct_field_uint(struct bt_ctf_field *struct_field, +struct bt_field *get_struct_field_uint(struct bt_field *struct_field, const char *field_name) { - struct bt_ctf_field *field = NULL; - struct bt_ctf_field_type *ft = NULL; + struct bt_field *field = NULL; + struct bt_field_type *ft = NULL; - field = bt_ctf_field_structure_get_field_by_name(struct_field, + field = bt_field_structure_get_field_by_name(struct_field, field_name); if (!field) { BT_LOGV_STR("`%s` field does not exist."); goto end; } - if (!bt_ctf_field_is_integer(field)) { + if (!bt_field_is_integer(field)) { BT_LOGV("Skipping `%s` field because its type is not an integer field type: " "field-addr=%p, ft-addr=%p, ft-id=%s", field_name, - field, ft, bt_ctf_field_type_id_string( - bt_ctf_field_type_get_type_id(ft))); + field, ft, bt_field_type_id_string( + bt_field_type_get_type_id(ft))); BT_PUT(field); goto end; } - ft = bt_ctf_field_get_type(field); - assert(ft); + ft = bt_field_get_type(field); + BT_ASSERT(ft); - if (bt_ctf_field_type_integer_is_signed(ft)) { + if (bt_field_type_integer_is_signed(ft)) { BT_LOGV("Skipping `%s` integer field because its type is signed: " "field-addr=%p, ft-addr=%p", field_name, field, ft); BT_PUT(field); @@ -1258,14 +1259,14 @@ end: } static -uint64_t get_packet_context_events_discarded(struct bt_ctf_packet *packet) +uint64_t get_packet_context_events_discarded(struct bt_packet *packet) { - struct bt_ctf_field *packet_context = NULL; - struct bt_ctf_field *field = NULL; + struct bt_field *packet_context = NULL; + struct bt_field *field = NULL; uint64_t retval = -1ULL; int ret; - packet_context = bt_ctf_packet_get_context(packet); + packet_context = bt_packet_get_context(packet); if (!packet_context) { goto end; } @@ -1278,8 +1279,8 @@ uint64_t get_packet_context_events_discarded(struct bt_ctf_packet *packet) goto end; } - assert(bt_ctf_field_is_integer(field)); - ret = bt_ctf_field_unsigned_integer_get_value(field, &retval); + BT_ASSERT(bt_field_is_integer(field)); + ret = bt_field_unsigned_integer_get_value(field, &retval); if (ret) { BT_LOGV("Cannot get raw value of packet's context field's `events_discarded` integer field: " "packet-addr=%p, field-addr=%p", @@ -1295,14 +1296,14 @@ end: } static -uint64_t get_packet_context_packet_seq_num(struct bt_ctf_packet *packet) +uint64_t get_packet_context_packet_seq_num(struct bt_packet *packet) { - struct bt_ctf_field *packet_context = NULL; - struct bt_ctf_field *field = NULL; + struct bt_field *packet_context = NULL; + struct bt_field *field = NULL; uint64_t retval = -1ULL; int ret; - packet_context = bt_ctf_packet_get_context(packet); + packet_context = bt_packet_get_context(packet); if (!packet_context) { goto end; } @@ -1315,8 +1316,8 @@ uint64_t get_packet_context_packet_seq_num(struct bt_ctf_packet *packet) goto end; } - assert(bt_ctf_field_is_integer(field)); - ret = bt_ctf_field_unsigned_integer_get_value(field, &retval); + BT_ASSERT(bt_field_is_integer(field)); + ret = bt_field_unsigned_integer_get_value(field, &retval); if (ret) { BT_LOGV("Cannot get raw value of packet's context field's `packet_seq_num` integer field: " "packet-addr=%p, field-addr=%p", @@ -1334,9 +1335,9 @@ end: static int handle_discarded_packets( struct bt_notification_iterator_private_connection *iterator, - struct bt_ctf_packet *packet, - struct bt_ctf_clock_value *ts_begin, - struct bt_ctf_clock_value *ts_end, + struct bt_packet *packet, + struct bt_clock_value *ts_begin, + struct bt_clock_value *ts_end, struct stream_state *stream_state) { struct bt_notification *notif = NULL; @@ -1409,9 +1410,9 @@ end: static int handle_discarded_events( struct bt_notification_iterator_private_connection *iterator, - struct bt_ctf_packet *packet, - struct bt_ctf_clock_value *ts_begin, - struct bt_ctf_clock_value *ts_end, + struct bt_packet *packet, + struct bt_clock_value *ts_begin, + struct bt_clock_value *ts_end, struct stream_state *stream_state) { struct bt_notification *notif = NULL; @@ -1467,14 +1468,14 @@ end: } static -int get_field_clock_value(struct bt_ctf_field *root_field, +int get_field_clock_value(struct bt_field *root_field, const char *field_name, - struct bt_ctf_clock_value **user_clock_val) + struct bt_clock_value **user_clock_val) { - struct bt_ctf_field *field; - struct bt_ctf_field_type *ft = NULL; - struct bt_ctf_clock_class *clock_class = NULL; - struct bt_ctf_clock_value *clock_value = NULL; + struct bt_field *field; + struct bt_field_type *ft = NULL; + struct bt_clock_class *clock_class = NULL; + struct bt_clock_value *clock_value = NULL; uint64_t val; int ret = 0; @@ -1484,9 +1485,9 @@ int get_field_clock_value(struct bt_ctf_field *root_field, goto end; } - ft = bt_ctf_field_get_type(field); - assert(ft); - clock_class = bt_ctf_field_type_integer_get_mapped_clock_class(ft); + ft = bt_field_get_type(field); + BT_ASSERT(ft); + clock_class = bt_field_type_integer_get_mapped_clock_class(ft); if (!clock_class) { BT_LOGW("Integer field type has no mapped clock class but it's expected to have one: " "ft-addr=%p", ft); @@ -1494,7 +1495,7 @@ int get_field_clock_value(struct bt_ctf_field *root_field, goto end; } - ret = bt_ctf_field_unsigned_integer_get_value(field, &val); + ret = bt_field_unsigned_integer_get_value(field, &val); if (ret) { BT_LOGW("Cannot get integer field's raw value: " "field-addr=%p", field); @@ -1502,7 +1503,7 @@ int get_field_clock_value(struct bt_ctf_field *root_field, goto end; } - clock_value = bt_ctf_clock_value_create(clock_class, val); + clock_value = bt_clock_value_create(clock_class, val); if (!clock_value) { BT_LOGE_STR("Cannot create clock value from clock class."); ret = -1; @@ -1522,16 +1523,16 @@ end: } static -int get_ts_begin_ts_end_from_packet(struct bt_ctf_packet *packet, - struct bt_ctf_clock_value **user_ts_begin, - struct bt_ctf_clock_value **user_ts_end) +int get_ts_begin_ts_end_from_packet(struct bt_packet *packet, + struct bt_clock_value **user_ts_begin, + struct bt_clock_value **user_ts_end) { - struct bt_ctf_field *packet_context = NULL; - struct bt_ctf_clock_value *ts_begin = NULL; - struct bt_ctf_clock_value *ts_end = NULL; + struct bt_field *packet_context = NULL; + struct bt_clock_value *ts_begin = NULL; + struct bt_clock_value *ts_end = NULL; int ret = 0; - packet_context = bt_ctf_packet_get_context(packet); + packet_context = bt_packet_get_context(packet); if (!packet_context) { goto end; } @@ -1570,10 +1571,10 @@ end: static int handle_discarded_elements( struct bt_notification_iterator_private_connection *iterator, - struct bt_ctf_packet *packet, struct stream_state *stream_state) + struct bt_packet *packet, struct stream_state *stream_state) { - struct bt_ctf_clock_value *ts_begin = NULL; - struct bt_ctf_clock_value *ts_end = NULL; + struct bt_clock_value *ts_begin = NULL; + struct bt_clock_value *ts_end = NULL; int ret; ret = get_ts_begin_ts_end_from_packet(packet, &ts_begin, &ts_end); @@ -1612,7 +1613,7 @@ static int handle_packet_switch( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *packet_begin_notif, - struct bt_ctf_packet *new_packet, + struct bt_packet *new_packet, struct stream_state *stream_state) { int ret = 0; @@ -1672,13 +1673,13 @@ static int handle_notif_stream_begin( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *notif, - struct bt_ctf_stream *notif_stream) + struct bt_stream *notif_stream) { int ret = 0; struct stream_state *stream_state; - assert(notif->type == BT_NOTIFICATION_TYPE_STREAM_BEGIN); - assert(notif_stream); + BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_STREAM_BEGIN); + BT_ASSERT(notif_stream); ret = ensure_stream_state_exists(iterator, notif, notif_stream, &stream_state); if (ret) { @@ -1699,13 +1700,13 @@ static int handle_notif_stream_end( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *notif, - struct bt_ctf_stream *notif_stream) + struct bt_stream *notif_stream) { int ret = 0; struct stream_state *stream_state; - assert(notif->type == BT_NOTIFICATION_TYPE_STREAM_END); - assert(notif_stream); + BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_STREAM_END); + BT_ASSERT(notif_stream); ret = ensure_stream_state_exists(iterator, NULL, notif_stream, &stream_state); if (ret) { @@ -1734,14 +1735,14 @@ static int handle_notif_discarded_elements( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *notif, - struct bt_ctf_stream *notif_stream) + struct bt_stream *notif_stream) { int ret = 0; struct stream_state *stream_state; - assert(notif->type == BT_NOTIFICATION_TYPE_DISCARDED_EVENTS || + BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_DISCARDED_EVENTS || notif->type == BT_NOTIFICATION_TYPE_DISCARDED_PACKETS); - assert(notif_stream); + BT_ASSERT(notif_stream); ret = ensure_stream_state_exists(iterator, NULL, notif_stream, &stream_state); if (ret) { @@ -1763,14 +1764,14 @@ static int handle_notif_packet_begin( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *notif, - struct bt_ctf_stream *notif_stream, - struct bt_ctf_packet *notif_packet) + struct bt_stream *notif_stream, + struct bt_packet *notif_packet) { int ret = 0; struct stream_state *stream_state; - assert(notif->type == BT_NOTIFICATION_TYPE_PACKET_BEGIN); - assert(notif_packet); + BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_PACKET_BEGIN); + BT_ASSERT(notif_packet); ret = ensure_stream_state_exists(iterator, NULL, notif_stream, &stream_state); if (ret) { @@ -1797,14 +1798,14 @@ static int handle_notif_packet_end( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *notif, - struct bt_ctf_stream *notif_stream, - struct bt_ctf_packet *notif_packet) + struct bt_stream *notif_stream, + struct bt_packet *notif_packet) { int ret = 0; struct stream_state *stream_state; - assert(notif->type == BT_NOTIFICATION_TYPE_PACKET_END); - assert(notif_packet); + BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_PACKET_END); + BT_ASSERT(notif_packet); ret = ensure_stream_state_exists(iterator, NULL, notif_stream, &stream_state); if (ret) { @@ -1834,14 +1835,14 @@ static int handle_notif_event( struct bt_notification_iterator_private_connection *iterator, struct bt_notification *notif, - struct bt_ctf_stream *notif_stream, - struct bt_ctf_packet *notif_packet) + struct bt_stream *notif_stream, + struct bt_packet *notif_packet) { int ret = 0; struct stream_state *stream_state; - assert(notif->type == BT_NOTIFICATION_TYPE_EVENT); - assert(notif_packet); + BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_EVENT); + BT_ASSERT(notif_packet); ret = ensure_stream_state_exists(iterator, NULL, notif_stream, &stream_state); if (ret) { @@ -1871,11 +1872,11 @@ int enqueue_notification_and_automatic( struct bt_notification *notif) { int ret = 0; - struct bt_ctf_event *notif_event = NULL; - struct bt_ctf_stream *notif_stream = NULL; - struct bt_ctf_packet *notif_packet = NULL; + struct bt_event *notif_event = NULL; + struct bt_stream *notif_stream = NULL; + struct bt_packet *notif_packet = NULL; - assert(notif); + BT_ASSERT(notif); BT_LOGV("Enqueuing user notification and automatic notifications: " "iter-addr=%p, notif-addr=%p", iterator, notif); @@ -1887,27 +1888,27 @@ int enqueue_notification_and_automatic( switch (notif->type) { case BT_NOTIFICATION_TYPE_EVENT: notif_event = bt_notification_event_borrow_event(notif); - assert(notif_event); - notif_packet = bt_ctf_event_borrow_packet(notif_event); - assert(notif_packet); + BT_ASSERT(notif_event); + notif_packet = bt_event_borrow_packet(notif_event); + BT_ASSERT(notif_packet); break; case BT_NOTIFICATION_TYPE_STREAM_BEGIN: notif_stream = bt_notification_stream_begin_borrow_stream(notif); - assert(notif_stream); + BT_ASSERT(notif_stream); break; case BT_NOTIFICATION_TYPE_STREAM_END: notif_stream = bt_notification_stream_end_borrow_stream(notif); - assert(notif_stream); + BT_ASSERT(notif_stream); break; case BT_NOTIFICATION_TYPE_PACKET_BEGIN: notif_packet = bt_notification_packet_begin_borrow_packet(notif); - assert(notif_packet); + BT_ASSERT(notif_packet); break; case BT_NOTIFICATION_TYPE_PACKET_END: notif_packet = bt_notification_packet_end_borrow_packet(notif); - assert(notif_packet); + BT_ASSERT(notif_packet); break; case BT_NOTIFICATION_TYPE_INACTIVITY: /* Always valid */ @@ -1925,8 +1926,8 @@ int enqueue_notification_and_automatic( } if (notif_packet) { - notif_stream = bt_ctf_packet_borrow_stream(notif_packet); - assert(notif_stream); + notif_stream = bt_packet_borrow_stream(notif_packet); + BT_ASSERT(notif_stream); } if (!notif_stream) { @@ -2012,7 +2013,7 @@ int handle_end(struct bt_notification_iterator_private_connection *iterator) &stream_state_gptr)) { struct stream_state *stream_state = stream_state_gptr; - assert(stream_state_gptr); + BT_ASSERT(stream_state_gptr); if (stream_state->is_ended) { continue; @@ -2059,7 +2060,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications( BT_NOTIFICATION_ITERATOR_STATUS_OK; int ret; - assert(iterator); + BT_ASSERT(iterator); BT_LOGD("Ensuring that notification iterator's queue has at least one notification: " "iter-addr=%p, queue-size=%u, iter-state=%s", iterator, iterator->queue->length, @@ -2091,8 +2092,8 @@ enum bt_notification_iterator_status ensure_queue_has_notifications( break; } - assert(iterator->upstream_component); - assert(iterator->upstream_component->class); + BT_ASSERT(iterator->upstream_component); + BT_ASSERT(iterator->upstream_component->class); /* Pick the appropriate "next" method */ switch (iterator->upstream_component->class->type) { @@ -2102,7 +2103,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications( container_of(iterator->upstream_component->class, struct bt_component_class_source, parent); - assert(source_class->methods.iterator.next); + BT_ASSERT(source_class->methods.iterator.next); next_method = source_class->methods.iterator.next; break; } @@ -2112,7 +2113,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications( container_of(iterator->upstream_component->class, struct bt_component_class_filter, parent); - assert(filter_class->methods.iterator.next); + BT_ASSERT(filter_class->methods.iterator.next); next_method = filter_class->methods.iterator.next; break; } @@ -2124,7 +2125,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications( * Call the user's "next" method to get the next notification * and status. */ - assert(next_method); + BT_ASSERT(next_method); while (iterator->queue->length == 0) { BT_LOGD_STR("Calling user's \"next\" method."); @@ -2172,7 +2173,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications( goto end; } - assert(iterator->state == + BT_ASSERT(iterator->state == BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE); iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED; @@ -2267,7 +2268,7 @@ bt_notification_iterator_next(struct bt_notification_iterator *iterator) * Move the notification at the tail of the queue to the * iterator's current notification. */ - assert(priv_conn_iter->queue->length > 0); + BT_ASSERT(priv_conn_iter->queue->length > 0); notif = g_queue_pop_tail(priv_conn_iter->queue); bt_notification_iterator_replace_current_notification( iterator, notif); @@ -2314,7 +2315,7 @@ bt_notification_iterator_next(struct bt_notification_iterator *iterator) break; case BT_GRAPH_STATUS_OK: status = BT_NOTIFICATION_ITERATOR_STATUS_OK; - assert(bt_notification_iterator_borrow_current_notification(iterator)); + BT_ASSERT(bt_notification_iterator_borrow_current_notification(iterator)); break; default: /* Other errors */ @@ -2369,7 +2370,7 @@ bt_private_connection_private_notification_iterator_get_private_component( { return bt_private_component_from_component( bt_private_connection_notification_iterator_get_component( - (void *) bt_private_connection_notification_iterator_from_private(private_iterator))); + (void *) bt_private_connection_notification_iterator_borrow_from_private(private_iterator))); } static @@ -2424,7 +2425,7 @@ struct bt_notification_iterator *bt_output_port_notification_iterator_create( } graph = bt_component_get_graph(output_port_comp); - assert(graph); + BT_ASSERT(graph); /* Create notification iterator */ BT_LOGD("Creating notification iterator on output port: " @@ -2471,7 +2472,7 @@ struct bt_notification_iterator *bt_output_port_notification_iterator_create( */ colander_in_port = bt_component_sink_get_input_port_by_index( iterator->colander, 0); - assert(colander_in_port); + BT_ASSERT(colander_in_port); graph_status = bt_graph_connect_ports(iterator->graph, output_port, colander_in_port, NULL); if (graph_status != BT_GRAPH_STATUS_OK) { @@ -2514,7 +2515,7 @@ error: */ ret = bt_graph_remove_unconnected_component(iterator->graph, colander_comp); - assert(ret == 0); + BT_ASSERT(ret == 0); } BT_PUT(iterator); @@ -2526,3 +2527,12 @@ end: bt_put(graph); return (void *) iterator; } + +struct bt_notification_iterator * +bt_private_connection_notification_iterator_from_private( + struct bt_private_connection_private_notification_iterator *private_notification_iterator) +{ + return bt_get( + bt_private_connection_notification_iterator_borrow_from_private( + private_notification_iterator)); +}