#include <assert.h>
#include <stdlib.h>
-#define IGNORE_ABSOLUTE_PARAM_NAME "ignore-absolute"
+#define ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME "assume-absolute-clock-classes"
struct muxer_comp {
/* Array of struct bt_private_notification_iterator * (weak refs) */
/* Owned by this, NULL if ended */
struct bt_notification_iterator *notif_iter;
- /* Weak */
- struct bt_private_port *priv_port;
-
/*
* This flag is true if the upstream notification iterator's
* current notification must be considered for the multiplexing
}
muxer_upstream_notif_iter->notif_iter = bt_get(notif_iter);
- muxer_upstream_notif_iter->priv_port = priv_port;
muxer_upstream_notif_iter->is_valid = false;
g_ptr_array_add(muxer_notif_iter->muxer_upstream_notif_iters,
muxer_upstream_notif_iter);
}
static
-int ensure_available_input_port(struct bt_private_component *priv_comp)
+enum bt_component_status ensure_available_input_port(
+ struct bt_private_component *priv_comp)
{
struct muxer_comp *muxer_comp =
bt_private_component_get_user_data(priv_comp);
- int ret = 0;
+ enum bt_component_status status = BT_COMPONENT_STATUS_OK;
GString *port_name = NULL;
- void *priv_port = NULL;
assert(muxer_comp);
port_name = g_string_new("in");
if (!port_name) {
- ret = -1;
+ status = BT_COMPONENT_STATUS_NOMEM;
goto end;
}
g_string_append_printf(port_name, "%u", muxer_comp->next_port_num);
- priv_port = bt_private_component_filter_add_input_private_port(
- priv_comp, port_name->str, NULL);
- if (!priv_port) {
- ret = -1;
+ status = bt_private_component_filter_add_input_private_port(
+ priv_comp, port_name->str, NULL, NULL);
+ if (status != BT_COMPONENT_STATUS_OK) {
goto end;
}
g_string_free(port_name, TRUE);
}
- bt_put(priv_port);
- return ret;
+ return status;
}
static
-int create_output_port(struct bt_private_component *priv_comp)
+enum bt_component_status create_output_port(
+ struct bt_private_component *priv_comp)
{
- void *priv_port;
- int ret = 0;
-
- priv_port = bt_private_component_filter_add_output_private_port(
- priv_comp, "out", NULL);
- if (!priv_port) {
- ret = -1;
- }
-
- bt_put(priv_port);
- return ret;
+ return bt_private_component_filter_add_output_private_port(
+ priv_comp, "out", NULL, NULL);
}
static
goto error;
}
- ret = bt_value_map_insert_bool(params, IGNORE_ABSOLUTE_PARAM_NAME,
- false);
+ ret = bt_value_map_insert_bool(params,
+ ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, false);
if (ret) {
goto error;
}
}
ignore_absolute = bt_value_map_get(real_params,
- IGNORE_ABSOLUTE_PARAM_NAME);
+ ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
if (!bt_value_is_bool(ignore_absolute)) {
goto error;
}
muxer_comp->priv_comp = priv_comp;
ret = bt_private_component_set_user_data(priv_comp, muxer_comp);
assert(ret == 0);
- ret = ensure_available_input_port(priv_comp);
- if (ret) {
+ status = ensure_available_input_port(priv_comp);
+ if (status != BT_COMPONENT_STATUS_OK) {
goto error;
}
destroy_muxer_comp(muxer_comp);
ret = bt_private_component_set_user_data(priv_comp, NULL);
assert(ret == 0);
- status = BT_COMPONENT_STATUS_ERROR;
+
+ if (status == BT_COMPONENT_STATUS_OK) {
+ status = BT_COMPONENT_STATUS_ERROR;
+ }
end:
return status;
if (status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
goto end;
}
+
+ /*
+ * Remove this muxer upstream notification iterator
+ * if it's ended or canceled.
+ */
+ if (!muxer_upstream_notif_iter->notif_iter) {
+ /*
+ * Use g_ptr_array_remove_fast() because the
+ * order of those elements is not important.
+ */
+ g_ptr_array_remove_index_fast(
+ muxer_notif_iter->muxer_upstream_notif_iters,
+ i);
+ i--;
+ }
}
end: