iterator->auto_seek.msgs = NULL;
}
+ if (iterator->upstream_msg_iters) {
+ /*
+ * At this point the message iterator is finalized, so
+ * it's detached from any upstream message iterator.
+ */
+ BT_ASSERT(iterator->upstream_msg_iters->len == 0);
+ g_ptr_array_free(iterator->upstream_msg_iters, TRUE);
+ iterator->upstream_msg_iters = NULL;
+ }
+
destroy_base_message_iterator(obj);
}
void bt_self_component_port_input_message_iterator_try_finalize(
struct bt_self_component_port_input_message_iterator *iterator)
{
+ uint64_t i;
typedef void (*method_t)(void *);
struct bt_component_class *comp_class = NULL;
method(iterator);
}
+ /* Detach upstream message iterators */
+ for (i = 0; i < iterator->upstream_msg_iters->len; i++) {
+ struct bt_self_component_port_input_message_iterator *upstream_msg_iter =
+ iterator->upstream_msg_iters->pdata[i];
+
+ upstream_msg_iter->downstream_msg_iter = NULL;
+ }
+
+ g_ptr_array_set_size(iterator->upstream_msg_iters, 0);
+
+ /* Detach downstream message iterator */
+ if (iterator->downstream_msg_iter) {
+ gboolean existed;
+
+ BT_ASSERT(iterator->downstream_msg_iter->upstream_msg_iters);
+ existed = g_ptr_array_remove_fast(
+ iterator->downstream_msg_iter->upstream_msg_iters,
+ iterator);
+ BT_ASSERT(existed);
+ }
+
iterator->upstream_component = NULL;
iterator->upstream_port = NULL;
set_self_comp_port_input_msg_iterator_state(iterator,
static
struct bt_self_component_port_input_message_iterator *
-bt_self_component_port_input_message_iterator_create_initial(
- struct bt_component *upstream_comp,
- struct bt_port *upstream_port)
+create_self_component_input_port_message_iterator(
+ struct bt_self_message_iterator *self_downstream_msg_iter,
+ struct bt_self_component_port_input *self_port)
{
+ typedef enum bt_component_class_message_iterator_init_method_status (*init_method_t)(
+ void *, void *, void *);
+
int ret;
- struct bt_self_component_port_input_message_iterator *iterator = NULL;
+ init_method_t init_method = NULL;
+ struct bt_self_component_port_input_message_iterator *iterator =
+ NULL;
+ struct bt_self_component_port_input_message_iterator *downstream_msg_iter =
+ (void *) self_downstream_msg_iter;
+ struct bt_port *port = (void *) self_port;
+ struct bt_port *upstream_port;
+ struct bt_component *comp;
+ struct bt_component *upstream_comp;
+ struct bt_component_class *upstream_comp_cls;
- BT_ASSERT(upstream_comp);
+ BT_ASSERT_PRE_NON_NULL(port, "Input port");
+ comp = bt_port_borrow_component_inline(port);
+ BT_ASSERT_PRE(bt_port_is_connected(port),
+ "Input port is not connected: %![port-]+p", port);
+ BT_ASSERT_PRE(comp, "Input port is not part of a component: %![port-]+p",
+ port);
+ BT_ASSERT(port->connection);
+ upstream_port = port->connection->upstream_port;
BT_ASSERT(upstream_port);
- BT_ASSERT(bt_port_is_connected(upstream_port));
- BT_LIB_LOGI("Creating initial message iterator on self component input port: "
- "%![up-comp-]+c, %![up-port-]+p", upstream_comp, upstream_port);
- BT_ASSERT(bt_component_get_class_type(upstream_comp) ==
+ upstream_comp = bt_port_borrow_component_inline(upstream_port);
+ BT_ASSERT(upstream_comp);
+ BT_ASSERT_PRE(
+ bt_component_borrow_graph(upstream_comp)->config_state ==
+ BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED ||
+ bt_component_borrow_graph(upstream_comp)->config_state ==
+ BT_GRAPH_CONFIGURATION_STATE_CONFIGURED,
+ "Graph is not configured: %!+g",
+ bt_component_borrow_graph(upstream_comp));
+ upstream_comp_cls = upstream_comp->class;
+ BT_ASSERT(upstream_comp->class->type ==
BT_COMPONENT_CLASS_TYPE_SOURCE ||
- bt_component_get_class_type(upstream_comp) ==
+ upstream_comp->class->type ==
BT_COMPONENT_CLASS_TYPE_FILTER);
+ BT_LIB_LOGI("Creating message iterator on self component input port: "
+ "%![up-comp-]+c, %![up-port-]+p", upstream_comp, upstream_port);
iterator = g_new0(
struct bt_self_component_port_input_message_iterator, 1);
if (!iterator) {
}
iterator->last_ns_from_origin = INT64_MIN;
-
iterator->auto_seek.msgs = g_queue_new();
if (!iterator->auto_seek.msgs) {
BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GQueue.");
- ret = -1;
- goto end;
+ goto error;
+ }
+
+ iterator->upstream_msg_iters = g_ptr_array_new();
+ if (!iterator->upstream_msg_iters) {
+ BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
+ goto error;
}
iterator->upstream_component = upstream_comp;
can_seek_beginning_true;
}
- BT_LIB_LOGI("Created initial message iterator on self component input port: "
- "%![up-port-]+p, %![up-comp-]+c, %![iter-]+i",
- upstream_port, upstream_comp, iterator);
- goto end;
-
-error:
- BT_OBJECT_PUT_REF_AND_RESET(iterator);
-
-end:
- return iterator;
-}
-
-struct bt_self_component_port_input_message_iterator *
-bt_self_component_port_input_message_iterator_create(
- struct bt_self_component_port_input *self_port)
-{
- typedef enum bt_component_class_message_iterator_init_method_status (*init_method_t)(
- void *, void *, void *);
-
- init_method_t init_method = NULL;
- struct bt_self_component_port_input_message_iterator *iterator =
- NULL;
- struct bt_port *port = (void *) self_port;
- struct bt_port *upstream_port;
- struct bt_component *comp;
- struct bt_component *upstream_comp;
- struct bt_component_class *upstream_comp_cls;
-
- BT_ASSERT_PRE_NON_NULL(port, "Port");
- comp = bt_port_borrow_component_inline(port);
- BT_ASSERT_PRE(bt_port_is_connected(port),
- "Port is not connected: %![port-]+p", port);
- BT_ASSERT_PRE(comp, "Port is not part of a component: %![port-]+p",
- port);
- BT_ASSERT_PRE(!bt_component_graph_is_canceled(comp),
- "Port's component's graph is canceled: "
- "%![port-]+p, %![comp-]+c", port, comp);
- BT_ASSERT(port->connection);
- upstream_port = port->connection->upstream_port;
- BT_ASSERT(upstream_port);
- upstream_comp = bt_port_borrow_component_inline(upstream_port);
- BT_ASSERT(upstream_comp);
- BT_ASSERT_PRE(
- bt_component_borrow_graph(upstream_comp)->config_state !=
- BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
- "Graph is not configured: %!+g",
- bt_component_borrow_graph(upstream_comp));
- upstream_comp_cls = upstream_comp->class;
- BT_ASSERT(upstream_comp->class->type ==
- BT_COMPONENT_CLASS_TYPE_SOURCE ||
- upstream_comp->class->type ==
- BT_COMPONENT_CLASS_TYPE_FILTER);
- iterator = bt_self_component_port_input_message_iterator_create_initial(
- upstream_comp, upstream_port);
- if (!iterator) {
- BT_LIB_LOGE_APPEND_CAUSE(
- "Cannot create self component input port message iterator.");
- goto error;
- }
-
switch (upstream_comp_cls->type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
{
}
}
+ if (downstream_msg_iter) {
+ /* Set this message iterator's downstream message iterator */
+ iterator->downstream_msg_iter = downstream_msg_iter;
+
+ /*
+ * Add this message iterator to the downstream message
+ * iterator's array of upstream message iterators.
+ */
+ g_ptr_array_add(downstream_msg_iter->upstream_msg_iters,
+ iterator);
+ }
+
set_self_comp_port_input_msg_iterator_state(iterator,
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
g_ptr_array_add(port->connection->iterators, iterator);
return iterator;
}
+struct bt_self_component_port_input_message_iterator *
+bt_self_component_port_input_message_iterator_create_from_message_iterator(
+ struct bt_self_message_iterator *self_msg_iter,
+ struct bt_self_component_port_input *input_port)
+{
+ BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator");
+ return create_self_component_input_port_message_iterator(self_msg_iter,
+ input_port);
+}
+
+struct bt_self_component_port_input_message_iterator *
+bt_self_component_port_input_message_iterator_create_from_sink_component(
+ struct bt_self_component_sink *self_comp,
+ struct bt_self_component_port_input *input_port)
+{
+ BT_ASSERT_PRE_NON_NULL(self_comp, "Sink component");
+ return create_self_component_input_port_message_iterator(NULL,
+ input_port);
+}
+
void *bt_self_message_iterator_get_data(
const struct bt_self_message_iterator *self_iterator)
{
struct bt_self_component_port_input_message_iterator *iterator =
(void *) self_iterator;
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
return iterator->user_data;
}
struct bt_self_component_port_input_message_iterator *iterator =
(void *) self_iterator;
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
iterator->user_data = data;
BT_LIB_LOGD("Set message iterator's user data: "
"%!+i, user-data-addr=%p", iterator, data);
* time.
*/
-BT_ASSERT_POST_FUNC
+BT_ASSERT_POST_DEV_FUNC
static
bool clock_snapshots_are_monotonic_one(
struct bt_self_component_port_input_message_iterator *iterator,
return result;
}
-BT_ASSERT_POST_FUNC
+BT_ASSERT_POST_DEV_FUNC
static
bool clock_snapshots_are_monotonic(
struct bt_self_component_port_input_message_iterator *iterator,
* stream is compatible with what we've seen before.
*/
-BT_ASSERT_POST_FUNC
+BT_ASSERT_POST_DEV_FUNC
static
bool clock_classes_are_compatible_one(struct bt_self_component_port_input_message_iterator *iterator,
const struct bt_message *msg)
case CLOCK_EXPECTATION_NONE:
if (clock_class) {
- BT_ASSERT_POST_MSG("Expecting no clock class, got one: %![cc-]+K",
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting no clock class, got one: %![cc-]+K",
clock_class);
result = false;
goto end;
case CLOCK_EXPECTATION_ORIGIN_UNIX:
if (!clock_class) {
- BT_ASSERT_POST_MSG("Expecting a clock class, got none.");
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class, got none.");
result = false;
goto end;
}
if (!bt_clock_class_origin_is_unix_epoch(clock_class)) {
- BT_ASSERT_POST_MSG("Expecting a clock class with Unix epoch origin: %![cc-]+K",
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class with Unix epoch origin: %![cc-]+K",
clock_class);
result = false;
goto end;
case CLOCK_EXPECTATION_ORIGIN_OTHER_UUID:
if (!clock_class) {
- BT_ASSERT_POST_MSG("Expecting a clock class, got none.");
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class, got none.");
result = false;
goto end;
}
if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
- BT_ASSERT_POST_MSG("Expecting a clock class without Unix epoch origin: %![cc-]+K",
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class without Unix epoch origin: %![cc-]+K",
clock_class);
result = false;
goto end;
}
if (!clock_class_uuid) {
- BT_ASSERT_POST_MSG("Expecting a clock class with UUID: %![cc-]+K",
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class with UUID: %![cc-]+K",
clock_class);
result = false;
goto end;
}
if (bt_uuid_compare(iterator->clock_expectation.uuid, clock_class_uuid)) {
- BT_ASSERT_POST_MSG("Expecting a clock class with UUID, got one "
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class with UUID, got one "
"with a different UUID: %![cc-]+K, expected-uuid=%!u",
clock_class, iterator->clock_expectation.uuid);
result = false;
case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID:
if (!clock_class) {
- BT_ASSERT_POST_MSG("Expecting a clock class, got none.");
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class, got none.");
result = false;
goto end;
}
if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
- BT_ASSERT_POST_MSG("Expecting a clock class without Unix epoch origin: %![cc-]+K",
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class without Unix epoch origin: %![cc-]+K",
clock_class);
result = false;
goto end;
}
if (clock_class_uuid) {
- BT_ASSERT_POST_MSG("Expecting a clock class without UUID: %![cc-]+K",
+ BT_ASSERT_POST_DEV_MSG(
+ "Expecting a clock class without UUID: %![cc-]+K",
clock_class);
result = false;
goto end;
return result;
}
-BT_ASSERT_POST_FUNC
+BT_ASSERT_POST_DEV_FUNC
static
bool clock_classes_are_compatible(
struct bt_self_component_port_input_message_iterator *iterator,
bt_common_func_status_string(status), *user_count);
if (status == BT_FUNC_STATUS_OK) {
- BT_ASSERT_POST(clock_classes_are_compatible(iterator, msgs, *user_count),
+ BT_ASSERT_POST_DEV(clock_classes_are_compatible(iterator, msgs, *user_count),
"Clocks are not compatible");
- BT_ASSERT_POST(clock_snapshots_are_monotonic(iterator, msgs, *user_count),
+ BT_ASSERT_POST_DEV(clock_snapshots_are_monotonic(iterator, msgs, *user_count),
"Clock snapshots are not monotonic");
}
{
enum bt_message_iterator_next_status status = BT_FUNC_STATUS_OK;
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
- BT_ASSERT_PRE_NON_NULL(msgs, "Message array (output)");
- BT_ASSERT_PRE_NON_NULL(user_count, "Message count (output)");
- BT_ASSERT_PRE(iterator->state ==
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(msgs, "Message array (output)");
+ BT_ASSERT_PRE_DEV_NON_NULL(user_count, "Message count (output)");
+ BT_ASSERT_PRE_DEV(iterator->state ==
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE,
"Message iterator's \"next\" called, but "
"message iterator is in the wrong state: %!+i", iterator);
BT_ASSERT(iterator->upstream_component);
BT_ASSERT(iterator->upstream_component->class);
- BT_ASSERT_PRE(
+ BT_ASSERT_PRE_DEV(
bt_component_borrow_graph(iterator->upstream_component)->config_state !=
BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
"Graph is not configured: %!+g",
switch (status) {
case BT_FUNC_STATUS_OK:
- BT_ASSERT_POST(*user_count <= MSG_BATCH_SIZE,
+ BT_ASSERT_POST_DEV(*user_count <= MSG_BATCH_SIZE,
"Invalid returned message count: greater than "
"batch size: count=%" PRIu64 ", batch-size=%u",
*user_count, MSG_BATCH_SIZE);
enum bt_message_iterator_next_status status;
int graph_status;
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
- BT_ASSERT_PRE_NON_NULL(msgs_to_user, "Message array (output)");
- BT_ASSERT_PRE_NON_NULL(count_to_user, "Message count (output)");
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(msgs_to_user, "Message array (output)");
+ BT_ASSERT_PRE_DEV_NON_NULL(count_to_user, "Message count (output)");
BT_LIB_LOGD("Getting next output port message iterator's messages: "
"%!+i", iterator);
graph_status = bt_graph_consume_sink_no_check(iterator->graph,
iterator->colander);
switch (graph_status) {
- case BT_FUNC_STATUS_CANCELED:
case BT_FUNC_STATUS_AGAIN:
case BT_FUNC_STATUS_END:
case BT_FUNC_STATUS_MEMORY_ERROR:
bt_self_component_port_input_message_iterator_borrow_component(
struct bt_self_component_port_input_message_iterator *iterator)
{
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
return iterator->upstream_component;
}
bt_self_component_port_input_message_iterator_borrow_component_const(
const struct bt_self_component_port_input_message_iterator *iterator)
{
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
return iterator->upstream_component;
}
struct bt_self_component_port_input_message_iterator *iterator =
(void *) self_iterator;
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
return (void *) iterator->upstream_component;
}
struct bt_self_component_port_input_message_iterator *iterator =
(void *) self_iterator;
- BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
+ BT_ASSERT_PRE_DEV_NON_NULL(iterator, "Message iterator");
return (void *) iterator->upstream_port;
}
(const void *) msg;
clk_snapshot = event_msg->default_cs;
- BT_ASSERT_POST(clk_snapshot,
+ BT_ASSERT_POST_DEV(clk_snapshot,
"Event message has no default clock snapshot: %!+n",
event_msg);
break;
(const void *) msg;
clk_snapshot = packet_msg->default_cs;
- BT_ASSERT_POST(clk_snapshot,
+ BT_ASSERT_POST_DEV(clk_snapshot,
"Packet message has no default clock snapshot: %!+n",
packet_msg);
break;
struct bt_message_discarded_items *msg_disc_items =
(void *) msg;
- BT_ASSERT_POST(msg_disc_items->default_begin_cs &&
+ BT_ASSERT_POST_DEV(msg_disc_items->default_begin_cs &&
msg_disc_items->default_end_cs,
"Discarded events/packets message has no default clock snapshots: %!+n",
msg_disc_items);
* as we don't know if items were really
* discarded within the new time range.
*/
- uint64_t new_begin_raw_value;
+ uint64_t new_begin_raw_value = 0;
ret = bt_clock_class_clock_value_from_ns_from_origin(
msg_disc_items->default_end_cs->clock_class,
switch (status) {
case BT_FUNC_STATUS_OK:
- BT_ASSERT_POST(user_count <= MSG_BATCH_SIZE,
+ BT_ASSERT_POST_DEV(user_count <= MSG_BATCH_SIZE,
"Invalid returned message count: greater than "
"batch size: count=%" PRIu64 ", batch-size=%u",
user_count, MSG_BATCH_SIZE);
iterator));
}
+bt_bool bt_self_message_iterator_is_interrupted(
+ const struct bt_self_message_iterator *self_msg_iter)
+{
+ const struct bt_self_component_port_input_message_iterator *iterator =
+ (const void *) self_msg_iter;
+
+ BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator");
+ return (bt_bool) bt_graph_is_interrupted(iterator->graph);
+}
+
void bt_port_output_message_iterator_get_ref(
const struct bt_port_output_message_iterator *iterator)
{