unsigned int next_port_num;
size_t available_input_ports;
bool error;
+ bool initializing_muxer_notif_iter;
};
struct muxer_upstream_notif_iter {
case BT_NOTIFICATION_TYPE_INACTIVITY:
cc_prio_map =
- bt_notification_event_get_clock_class_priority_map(
+ bt_notification_inactivity_get_clock_class_priority_map(
notif);
break;
default:
goto error;
}
- if (!bt_ctf_clock_class_get_is_absolute(clock_class)) {
+ if (!bt_ctf_clock_class_is_absolute(clock_class)) {
// TODO: Allow this with an explicit parameter
goto error;
}
struct muxer_notif_iter *muxer_notif_iter)
{
struct bt_component *comp;
- uint64_t count;
- uint64_t i;
+ int64_t count;
+ int64_t i;
int ret = 0;
/*
*/
comp = bt_component_from_private_component(muxer_comp->priv_comp);
assert(comp);
- ret = bt_component_filter_get_input_port_count(comp, &count);
- if (ret) {
+ count = bt_component_filter_get_input_port_count(comp);
+ if (count < 0) {
goto end;
}
for (i = 0; i < count; i++) {
struct bt_private_port *priv_port =
- bt_private_component_filter_get_input_private_port_at_index(
+ bt_private_component_filter_get_input_private_port_by_index(
muxer_comp->priv_comp, i);
struct bt_port *port;
assert(priv_comp);
muxer_comp = bt_private_component_get_user_data(priv_comp);
assert(muxer_comp);
- muxer_notif_iter = g_new0(struct muxer_notif_iter, 1);
- if (!muxer_notif_iter) {
+
+ if (muxer_comp->initializing_muxer_notif_iter) {
+ /*
+ * Weird, unhandled situation: downstream creates a
+ * muxer notification iterator while creating another
+ * muxer notification iterator (same component).
+ */
goto error;
}
- ret = muxer_notif_iter_init_newly_connected_ports(muxer_comp,
- muxer_notif_iter);
- if (ret) {
+ muxer_comp->initializing_muxer_notif_iter = true;
+ muxer_notif_iter = g_new0(struct muxer_notif_iter, 1);
+ if (!muxer_notif_iter) {
goto error;
}
goto error;
}
+ /*
+ * Add the muxer notification iterator to the component's array
+ * of muxer notification iterators here because
+ * muxer_notif_iter_init_newly_connected_ports() can cause
+ * muxer_port_connected() to be called, which adds the newly
+ * connected port to each muxer notification iterator's list of
+ * newly connected ports.
+ */
+ g_ptr_array_add(muxer_comp->muxer_notif_iters, muxer_notif_iter);
+ ret = muxer_notif_iter_init_newly_connected_ports(muxer_comp,
+ muxer_notif_iter);
+ if (ret) {
+ goto error;
+ }
+
/* Set the initial "next" return value */
ret = muxer_notif_iter_set_next_next_return(muxer_comp,
muxer_notif_iter);
ret = bt_private_notification_iterator_set_user_data(priv_notif_iter,
muxer_notif_iter);
assert(ret == 0);
- g_ptr_array_add(muxer_comp->muxer_notif_iters, muxer_notif_iter);
goto end;
error:
+ if (g_ptr_array_index(muxer_comp->muxer_notif_iters,
+ muxer_comp->muxer_notif_iters->len - 1) == muxer_notif_iter) {
+ g_ptr_array_remove_index(muxer_comp->muxer_notif_iters,
+ muxer_comp->muxer_notif_iters->len - 1);
+ }
+
destroy_muxer_notif_iter(muxer_notif_iter);
ret = bt_private_notification_iterator_set_user_data(priv_notif_iter,
NULL);
status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
end:
+ muxer_comp->initializing_muxer_notif_iter = false;
bt_put(priv_comp);
return status;
}