lib: make trace IR API const-correct
[babeltrace.git] / plugins / utils / muxer / muxer.c
index ac48ceaefe5a392a4afebfe7429dd2d87aa0565b..7c5991abb3685806638fbae0f57f26d9dacfb91a 100644 (file)
@@ -151,7 +151,8 @@ struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter(
                goto end;
        }
 
-       muxer_upstream_notif_iter->notif_iter = bt_object_get_ref(self_notif_iter);
+       muxer_upstream_notif_iter->notif_iter = self_notif_iter;
+       bt_object_get_ref(muxer_upstream_notif_iter->notif_iter);
        muxer_upstream_notif_iter->notifs = g_queue_new();
        if (!muxer_upstream_notif_iter->notifs) {
                BT_LOGE_STR("Failed to allocate a GQueue.");
@@ -174,7 +175,7 @@ enum bt_self_component_status ensure_available_input_port(
                struct bt_self_component_filter *self_comp)
 {
        struct muxer_comp *muxer_comp = bt_self_component_get_data(
-               bt_self_component_filter_borrow_self_component(self_comp));
+               bt_self_component_filter_as_self_component(self_comp));
        enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
        GString *port_name = NULL;
 
@@ -243,18 +244,18 @@ void destroy_muxer_comp(struct muxer_comp *muxer_comp)
 }
 
 static
-struct bt_private_value *get_default_params(void)
+struct bt_value *get_default_params(void)
 {
-       struct bt_private_value *params;
+       struct bt_value *params;
        int ret;
 
-       params = bt_private_value_map_create();
+       params = bt_value_map_create();
        if (!params) {
                BT_LOGE_STR("Cannot create a map value object.");
                goto error;
        }
 
-       ret = bt_private_value_map_insert_bool_entry(params,
+       ret = bt_value_map_insert_bool_entry(params,
                ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, false);
        if (ret) {
                BT_LOGE_STR("Cannot add boolean value to map value object.");
@@ -271,11 +272,12 @@ end:
 }
 
 static
-int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
+int configure_muxer_comp(struct muxer_comp *muxer_comp,
+               const struct bt_value *params)
 {
-       struct bt_private_value *default_params = NULL;
-       struct bt_private_value *real_params = NULL;
-       struct bt_value *assume_absolute_clock_classes = NULL;
+       struct bt_value *default_params = NULL;
+       struct bt_value *real_params = NULL;
+       const struct bt_value *assume_absolute_clock_classes = NULL;
        int ret = 0;
        bt_bool bool_val;
 
@@ -287,7 +289,7 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
        }
 
        ret = bt_value_map_extend(&real_params,
-               bt_private_value_borrow_value(default_params), params);
+               default_params, params);
        if (ret) {
                BT_LOGE("Cannot extend default parameters map value: "
                        "muxer-comp-addr=%p, def-params-addr=%p, "
@@ -296,9 +298,8 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
                goto error;
        }
 
-       assume_absolute_clock_classes = bt_value_map_borrow_entry_value(
-               bt_private_value_borrow_value(real_params),
-               ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
+       assume_absolute_clock_classes = bt_value_map_borrow_entry_value(real_params,
+                                                                       ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
        if (assume_absolute_clock_classes &&
                        !bt_value_is_bool(assume_absolute_clock_classes)) {
                BT_LOGE("Expecting a boolean value for the `%s` parameter: "
@@ -358,7 +359,7 @@ enum bt_self_component_status muxer_init(
 
        muxer_comp->self_comp = self_comp;
        bt_self_component_set_data(
-               bt_self_component_filter_borrow_self_component(self_comp),
+               bt_self_component_filter_as_self_component(self_comp),
                muxer_comp);
        status = ensure_available_input_port(self_comp);
        if (status != BT_SELF_COMPONENT_STATUS_OK) {
@@ -387,7 +388,7 @@ enum bt_self_component_status muxer_init(
 error:
        destroy_muxer_comp(muxer_comp);
        bt_self_component_set_data(
-               bt_self_component_filter_borrow_self_component(self_comp),
+               bt_self_component_filter_as_self_component(self_comp),
                NULL);
 
        if (status == BT_SELF_COMPONENT_STATUS_OK) {
@@ -402,7 +403,7 @@ BT_HIDDEN
 void muxer_finalize(struct bt_self_component_filter *self_comp)
 {
        struct muxer_comp *muxer_comp = bt_self_component_get_data(
-               bt_self_component_filter_borrow_self_component(self_comp));
+               bt_self_component_filter_as_self_component(self_comp));
 
        BT_LOGD("Finalizing muxer component: comp-addr=%p",
                self_comp);
@@ -414,8 +415,8 @@ struct bt_self_component_port_input_notification_iterator *
 create_notif_iter_on_input_port(
                struct bt_self_component_port_input *self_port, int *ret)
 {
-       struct bt_port *port = bt_self_component_port_borrow_port(
-               bt_self_component_port_input_borrow_self_component_port(
+       struct bt_port *port = bt_self_component_port_as_port(
+               bt_self_component_port_input_as_self_component_port(
                        self_port));
        struct bt_self_component_port_input_notification_iterator *notif_iter =
                NULL;
@@ -542,8 +543,8 @@ int muxer_notif_iter_handle_newly_connected_ports(
                }
 
                self_port = node->data;
-               port = bt_self_component_port_borrow_port(
-                       bt_self_component_port_input_borrow_self_component_port(
+               port = bt_self_component_port_as_port(
+                       bt_self_component_port_input_as_self_component_port(
                                (self_port)));
                BT_ASSERT(port);
 
@@ -602,9 +603,9 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                struct bt_notification *notif, int64_t last_returned_ts_ns,
                int64_t *ts_ns)
 {
-       struct bt_clock_class *clock_class = NULL;
-       struct bt_clock_value *clock_value = NULL;
-       struct bt_event *event = NULL;
+       const struct bt_clock_class *clock_class = NULL;
+       const struct bt_clock_value *clock_value = NULL;
+       const struct bt_event *event = NULL;
        int ret = 0;
        const unsigned char *cc_uuid;
        const char *cc_name;
@@ -622,7 +623,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
        case BT_NOTIFICATION_TYPE_EVENT:
                event = bt_notification_event_borrow_event(notif);
                BT_ASSERT(event);
-               cv_status = bt_event_borrow_default_clock_value(event,
+               cv_status = bt_event_borrow_default_clock_value_const(event,
                        &clock_value);
                break;
 
@@ -656,7 +657,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                goto end;
        }
 
-       clock_class = bt_clock_value_borrow_clock_class(clock_value);
+       clock_class = bt_clock_value_borrow_clock_class_const(clock_value);
        BT_ASSERT(clock_class);
        cc_uuid = bt_clock_class_get_uuid(clock_class);
        cc_name = bt_clock_class_get_name(clock_class);
@@ -1174,7 +1175,7 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
         * handled by muxer_notif_iter_handle_newly_connected_ports().
         */
        count = bt_component_filter_get_input_port_count(
-               bt_self_component_filter_borrow_component_filter(
+               bt_self_component_filter_as_component_filter(
                        muxer_comp->self_comp));
        if (count < 0) {
                BT_LOGD("No input port to initialize for muxer component's notification iterator: "
@@ -1190,8 +1191,8 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
                struct bt_port *port;
 
                BT_ASSERT(self_port);
-               port = bt_self_component_port_borrow_port(
-                       bt_self_component_port_input_borrow_self_component_port(
+               port = bt_self_component_port_as_port(
+                       bt_self_component_port_input_as_self_component_port(
                                self_port));
                BT_ASSERT(port);
 
@@ -1238,7 +1239,7 @@ enum bt_self_notification_iterator_status muxer_notif_iter_init(
        int ret;
 
        muxer_comp = bt_self_component_get_data(
-               bt_self_component_filter_borrow_self_component(self_comp));
+               bt_self_component_filter_as_self_component(self_comp));
        BT_ASSERT(muxer_comp);
        BT_LOGD("Initializing muxer component's notification iterator: "
                "comp-addr=%p, muxer-comp-addr=%p, notif-iter-addr=%p",
@@ -1389,12 +1390,12 @@ enum bt_self_component_status muxer_input_port_connected(
                struct bt_port_output *other_port)
 {
        enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
-       struct bt_port *port = bt_self_component_port_borrow_port(
-               bt_self_component_port_input_borrow_self_component_port(
+       struct bt_port *port = bt_self_component_port_as_port(
+               bt_self_component_port_input_as_self_component_port(
                        self_port));
        struct muxer_comp *muxer_comp =
                bt_self_component_get_data(
-                       bt_self_component_filter_borrow_self_component(
+                       bt_self_component_filter_as_self_component(
                                self_comp));
        size_t i;
        int ret;
@@ -1407,7 +1408,7 @@ enum bt_self_component_status muxer_input_port_connected(
                "other-port-addr=%p, other-port-name=\"%s\"",
                self_comp, muxer_comp, self_port, bt_port_get_name(port),
                other_port,
-               bt_port_get_name(bt_port_output_borrow_port(other_port)));
+               bt_port_get_name(bt_port_output_as_port(other_port)));
 
        for (i = 0; i < muxer_comp->muxer_notif_iters->len; i++) {
                struct muxer_notif_iter *muxer_notif_iter =
@@ -1465,11 +1466,11 @@ void muxer_input_port_disconnected(
 {
        struct muxer_comp *muxer_comp =
                bt_self_component_get_data(
-                       bt_self_component_filter_borrow_self_component(
+                       bt_self_component_filter_as_self_component(
                                self_component));
        struct bt_port *port =
-               bt_self_component_port_borrow_port(
-                       bt_self_component_port_input_borrow_self_component_port(
+               bt_self_component_port_as_port(
+                       bt_self_component_port_input_as_self_component_port(
                                self_port));
 
        BT_ASSERT(port);
This page took 0.028844 seconds and 4 git commands to generate.