lib: use object pool for event and packet notifications
[babeltrace.git] / plugins / utils / muxer / muxer.c
index cd9cc3f2f041fba30aed0ce957227c61cc2bccbe..1f87b2162b3b73b6a9e43b515df094a4bea2504c 100644 (file)
 
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/ctf-ir/clock-class.h>
-#include <babeltrace/ctf-ir/event.h>
-#include <babeltrace/graph/clock-class-priority-map.h>
-#include <babeltrace/graph/component-filter.h>
-#include <babeltrace/graph/component.h>
+#include <babeltrace/babeltrace.h>
+#include <babeltrace/values-internal.h>
 #include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/notification-event.h>
-#include <babeltrace/graph/notification-inactivity.h>
-#include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/notification-iterator-internal.h>
-#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/port.h>
-#include <babeltrace/graph/private-component-filter.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-connection.h>
-#include <babeltrace/graph/private-notification-iterator.h>
-#include <babeltrace/graph/private-port.h>
-#include <babeltrace/graph/connection.h>
 #include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/values-internal.h>
 #include <plugins-common.h>
 #include <glib.h>
 #include <stdbool.h>
 #include <inttypes.h>
-#include <assert.h>
+#include <babeltrace/assert-internal.h>
 #include <stdlib.h>
 #include <string.h>
 
 #define ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME       "assume-absolute-clock-classes"
 
 struct muxer_comp {
-       /* Array of struct bt_private_notification_iterator * (weak refs) */
+       /*
+        * Array of struct
+        * bt_private_connection_private_notification_iterator *
+        * (weak refs)
+        */
        GPtrArray *muxer_notif_iters;
 
        /* Weak ref */
@@ -117,7 +105,7 @@ struct muxer_notif_iter {
        GList *newly_connected_priv_ports;
 
        /* Next thing to return by the "next" method */
-       struct bt_notification_iterator_next_return next_next_return;
+       struct bt_notification_iterator_next_method_return next_next_return;
 
        /* Last time returned in a notification */
        int64_t last_returned_ts_ns;
@@ -186,7 +174,7 @@ enum bt_component_status ensure_available_input_port(
        enum bt_component_status status = BT_COMPONENT_STATUS_OK;
        GString *port_name = NULL;
 
-       assert(muxer_comp);
+       BT_ASSERT(muxer_comp);
 
        if (muxer_comp->available_input_ports >= 1) {
                goto end;
@@ -240,7 +228,8 @@ void destroy_muxer_comp(struct muxer_comp *muxer_comp)
 
        BT_LOGD("Destroying muxer component: muxer-comp-addr=%p, "
                "muxer-notif-iter-count=%u", muxer_comp,
-               muxer_comp->muxer_notif_iters->len);
+               muxer_comp->muxer_notif_iters ?
+                       muxer_comp->muxer_notif_iters->len : 0);
 
        if (muxer_comp->muxer_notif_iters) {
                g_ptr_array_free(muxer_comp->muxer_notif_iters, TRUE);
@@ -302,9 +291,10 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
                goto error;
        }
 
-       assume_absolute_clock_classes = bt_value_map_get(real_params,
+       assume_absolute_clock_classes = bt_value_map_borrow(real_params,
                ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
-       if (!bt_value_is_bool(assume_absolute_clock_classes)) {
+       if (assume_absolute_clock_classes &&
+                       !bt_value_is_bool(assume_absolute_clock_classes)) {
                BT_LOGE("Expecting a boolean value for the `%s` parameter: "
                        "muxer-comp-addr=%p, value-type=%s",
                        ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, muxer_comp,
@@ -314,7 +304,7 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
        }
 
        ret = bt_value_bool_get(assume_absolute_clock_classes, &bool_val);
-       assert(ret == 0);
+       BT_ASSERT(ret == 0);
        muxer_comp->assume_absolute_clock_classes = (bool) bool_val;
        BT_LOGD("Configured muxer component: muxer-comp-addr=%p, "
                "assume-absolute-clock-classes=%d",
@@ -327,7 +317,6 @@ error:
 end:
        bt_put(default_params);
        bt_put(real_params);
-       bt_put(assume_absolute_clock_classes);
        return ret;
 }
 
@@ -364,7 +353,7 @@ enum bt_component_status muxer_init(
 
        muxer_comp->priv_comp = priv_comp;
        ret = bt_private_component_set_user_data(priv_comp, muxer_comp);
-       assert(ret == 0);
+       BT_ASSERT(ret == 0);
        status = ensure_available_input_port(priv_comp);
        if (status != BT_COMPONENT_STATUS_OK) {
                BT_LOGE("Cannot ensure that at least one muxer component's input port is available: "
@@ -392,7 +381,7 @@ enum bt_component_status muxer_init(
 error:
        destroy_muxer_comp(muxer_comp);
        ret = bt_private_component_set_user_data(priv_comp, NULL);
-       assert(ret == 0);
+       BT_ASSERT(ret == 0);
 
        if (status == BT_COMPONENT_STATUS_OK) {
                status = BT_COMPONENT_STATUS_ERROR;
@@ -417,23 +406,23 @@ static
 struct bt_notification_iterator *create_notif_iter_on_input_port(
                struct bt_private_port *priv_port, int *ret)
 {
-       struct bt_port *port = bt_port_from_private_port(priv_port);
+       struct bt_port *port = bt_port_borrow_from_private(priv_port);
        struct bt_notification_iterator *notif_iter = NULL;
        struct bt_private_connection *priv_conn = NULL;
        enum bt_connection_status conn_status;
 
-       assert(ret);
+       BT_ASSERT(ret);
        *ret = 0;
-       assert(port);
-       assert(bt_port_is_connected(port));
+       BT_ASSERT(port);
+       BT_ASSERT(bt_port_is_connected(port));
        priv_conn = bt_private_port_get_private_connection(priv_port);
-       assert(priv_conn);
+       BT_ASSERT(priv_conn);
 
        // TODO: Advance the iterator to >= the time of the latest
        //       returned notification by the muxer notification
        //       iterator which creates it.
        conn_status = bt_private_connection_create_notification_iterator(
-               priv_conn, NULL, &notif_iter);
+               priv_conn, &notif_iter);
        if (conn_status != BT_CONNECTION_STATUS_OK) {
                BT_LOGE("Cannot create upstream notification iterator on input port's connection: "
                        "port-addr=%p, port-name=\"%s\", conn-addr=%p, "
@@ -450,7 +439,6 @@ struct bt_notification_iterator *create_notif_iter_on_input_port(
                port, bt_port_get_name(port), priv_conn, notif_iter);
 
 end:
-       bt_put(port);
        bt_put(priv_conn);
        return notif_iter;
 }
@@ -541,8 +529,8 @@ int muxer_notif_iter_handle_newly_connected_ports(
                }
 
                priv_port = node->data;
-               port = bt_port_from_private_port(priv_port);
-               assert(port);
+               port = bt_port_borrow_from_private(priv_port);
+               BT_ASSERT(port);
 
                if (!bt_port_is_connected(port)) {
                        /*
@@ -554,12 +542,11 @@ int muxer_notif_iter_handle_newly_connected_ports(
                        goto remove_node;
                }
 
-               BT_PUT(port);
                upstream_notif_iter = create_notif_iter_on_input_port(priv_port,
                        &ret);
                if (ret) {
                        /* create_notif_iter_on_input_port() logs errors */
-                       assert(!upstream_notif_iter);
+                       BT_ASSERT(!upstream_notif_iter);
                        goto error;
                }
 
@@ -578,7 +565,6 @@ int muxer_notif_iter_handle_newly_connected_ports(
 
 remove_node:
                bt_put(upstream_notif_iter);
-               bt_put(port);
                muxer_notif_iter->newly_connected_priv_ports =
                        g_list_delete_link(
                                muxer_notif_iter->newly_connected_priv_ports,
@@ -603,15 +589,15 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                int64_t *ts_ns)
 {
        struct bt_clock_class_priority_map *cc_prio_map = NULL;
-       struct bt_ctf_clock_class *clock_class = NULL;
-       struct bt_ctf_clock_value *clock_value = NULL;
-       struct bt_ctf_event *event = NULL;
+       struct bt_clock_class *clock_class = NULL;
+       struct bt_clock_value *clock_value = NULL;
+       struct bt_event *event = NULL;
        int ret = 0;
        const unsigned char *cc_uuid;
        const char *cc_name;
 
-       assert(notif);
-       assert(ts_ns);
+       BT_ASSERT(notif);
+       BT_ASSERT(ts_ns);
 
        BT_LOGV("Getting notification's timestamp: "
                "muxer-notif-iter-addr=%p, notif-addr=%p, "
@@ -621,13 +607,13 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
        switch (bt_notification_get_type(notif)) {
        case BT_NOTIFICATION_TYPE_EVENT:
                cc_prio_map =
-                       bt_notification_event_get_clock_class_priority_map(
+                       bt_notification_event_borrow_clock_class_priority_map(
                                notif);
                break;
 
        case BT_NOTIFICATION_TYPE_INACTIVITY:
                cc_prio_map =
-                       bt_notification_inactivity_get_clock_class_priority_map(
+                       bt_notification_inactivity_borrow_clock_class_priority_map(
                                notif);
                break;
        default:
@@ -649,14 +635,14 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
         * the youngest.
         */
        if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) == 0) {
-               BT_LOGV_STR("Notification's clock class priorty map contains 0 clock classes: "
+               BT_LOGV_STR("Notification's clock class priority map contains 0 clock classes: "
                        "using the last returned timestamp.");
                *ts_ns = last_returned_ts_ns;
                goto end;
        }
 
        clock_class =
-               bt_clock_class_priority_map_get_highest_priority_clock_class(
+               bt_clock_class_priority_map_borrow_highest_priority_clock_class(
                        cc_prio_map);
        if (!clock_class) {
                BT_LOGE("Cannot get the clock class with the highest priority from clock class priority map: "
@@ -664,8 +650,8 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                goto error;
        }
 
-       cc_uuid = bt_ctf_clock_class_get_uuid(clock_class);
-       cc_name = bt_ctf_clock_class_get_name(clock_class);
+       cc_uuid = bt_clock_class_get_uuid(clock_class);
+       cc_name = bt_clock_class_get_name(clock_class);
 
        if (muxer_notif_iter->clock_class_expectation ==
                        MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ANY) {
@@ -676,7 +662,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                 * the iterator without a true
                 * `assume-absolute-clock-classes` parameter.
                 */
-               if (bt_ctf_clock_class_is_absolute(clock_class)) {
+               if (bt_clock_class_is_absolute(clock_class)) {
                        /* Expect absolute clock classes */
                        muxer_notif_iter->clock_class_expectation =
                                MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE;
@@ -704,7 +690,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
        if (!muxer_comp->assume_absolute_clock_classes) {
                switch (muxer_notif_iter->clock_class_expectation) {
                case MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE:
-                       if (!bt_ctf_clock_class_is_absolute(clock_class)) {
+                       if (!bt_clock_class_is_absolute(clock_class)) {
                                BT_LOGE("Expecting an absolute clock class, "
                                        "but got a non-absolute one: "
                                        "clock-class-addr=%p, clock-class-name=\"%s\"",
@@ -713,7 +699,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                        }
                        break;
                case MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID:
-                       if (bt_ctf_clock_class_is_absolute(clock_class)) {
+                       if (bt_clock_class_is_absolute(clock_class)) {
                                BT_LOGE("Expecting a non-absolute clock class with no UUID, "
                                        "but got an absolute one: "
                                        "clock-class-addr=%p, clock-class-name=\"%s\"",
@@ -747,7 +733,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                        }
                        break;
                case MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID:
-                       if (bt_ctf_clock_class_is_absolute(clock_class)) {
+                       if (bt_clock_class_is_absolute(clock_class)) {
                                BT_LOGE("Expecting a non-absolute clock class with a specific UUID, "
                                        "but got an absolute one: "
                                        "clock-class-addr=%p, clock-class-name=\"%s\"",
@@ -817,13 +803,13 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
 
        switch (bt_notification_get_type(notif)) {
        case BT_NOTIFICATION_TYPE_EVENT:
-               event = bt_notification_event_get_event(notif);
-               assert(event);
-               clock_value = bt_ctf_event_get_clock_value(event,
+               event = bt_notification_event_borrow_event(notif);
+               BT_ASSERT(event);
+               clock_value = bt_event_borrow_clock_value(event,
                        clock_class);
                break;
        case BT_NOTIFICATION_TYPE_INACTIVITY:
-               clock_value = bt_notification_inactivity_get_clock_value(
+               clock_value = bt_notification_inactivity_borrow_clock_value(
                        notif, clock_class);
                break;
        default:
@@ -839,7 +825,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                goto error;
        }
 
-       ret = bt_ctf_clock_value_get_value_ns_from_epoch(clock_value, ts_ns);
+       ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ts_ns);
        if (ret) {
                BT_LOGE("Cannot get nanoseconds from Epoch of clock value: "
                        "clock-value-addr=%p", clock_value);
@@ -860,10 +846,6 @@ end:
                        *ts_ns);
        }
 
-       bt_put(cc_prio_map);
-       bt_put(event);
-       bt_put(clock_class);
-       bt_put(clock_value);
        return ret;
 }
 
@@ -898,9 +880,9 @@ muxer_notif_iter_youngest_upstream_notif_iter(
        enum bt_notification_iterator_status status =
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
 
-       assert(muxer_comp);
-       assert(muxer_notif_iter);
-       assert(muxer_upstream_notif_iter);
+       BT_ASSERT(muxer_comp);
+       BT_ASSERT(muxer_notif_iter);
+       BT_ASSERT(muxer_upstream_notif_iter);
        *muxer_upstream_notif_iter = NULL;
 
        for (i = 0; i < muxer_notif_iter->muxer_upstream_notif_iters->len; i++) {
@@ -917,13 +899,12 @@ muxer_notif_iter_youngest_upstream_notif_iter(
                        continue;
                }
 
-               assert(cur_muxer_upstream_notif_iter->is_valid);
-               notif = bt_notification_iterator_get_notification(
+               BT_ASSERT(cur_muxer_upstream_notif_iter->is_valid);
+               notif = bt_notification_iterator_borrow_notification(
                        cur_muxer_upstream_notif_iter->notif_iter);
-               assert(notif);
+               BT_ASSERT(notif);
                ret = get_notif_ts_ns(muxer_comp, muxer_notif_iter, notif,
                        muxer_notif_iter->last_returned_ts_ns, &notif_ts_ns);
-               bt_put(notif);
                if (ret) {
                        /* get_notif_ts_ns() logs errors */
                        *muxer_upstream_notif_iter = NULL;
@@ -1033,12 +1014,12 @@ end:
 }
 
 static
-struct bt_notification_iterator_next_return muxer_notif_iter_do_next(
+struct bt_notification_iterator_next_method_return muxer_notif_iter_do_next(
                struct muxer_comp *muxer_comp,
                struct muxer_notif_iter *muxer_notif_iter)
 {
        struct muxer_upstream_notif_iter *muxer_upstream_notif_iter = NULL;
-       struct bt_notification_iterator_next_return next_return = {
+       struct bt_notification_iterator_next_method_return next_return = {
                .notification = NULL,
                .status = BT_NOTIFICATION_ITERATOR_STATUS_OK,
        };
@@ -1080,7 +1061,7 @@ struct bt_notification_iterator_next_return muxer_notif_iter_do_next(
                }
        }
 
-       assert(!muxer_notif_iter->newly_connected_priv_ports);
+       BT_ASSERT(!muxer_notif_iter->newly_connected_priv_ports);
 
        /*
         * At this point we know that all the existing upstream
@@ -1123,11 +1104,11 @@ struct bt_notification_iterator_next_return muxer_notif_iter_do_next(
                "muxer-upstream-notif-iter-wrap-addr=%p, "
                "ts=%" PRId64,
                muxer_notif_iter, muxer_upstream_notif_iter, next_return_ts);
-       assert(next_return.status == BT_NOTIFICATION_ITERATOR_STATUS_OK);
-       assert(muxer_upstream_notif_iter);
+       BT_ASSERT(next_return.status == BT_NOTIFICATION_ITERATOR_STATUS_OK);
+       BT_ASSERT(muxer_upstream_notif_iter);
        next_return.notification = bt_notification_iterator_get_notification(
                muxer_upstream_notif_iter->notif_iter);
-       assert(next_return.notification);
+       BT_ASSERT(next_return.notification);
 
        /*
         * We invalidate the upstream notification iterator so that, the
@@ -1175,8 +1156,8 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
         * iterator's list of newly connected ports. They will be
         * handled by muxer_notif_iter_handle_newly_connected_ports().
         */
-       comp = bt_component_from_private_component(muxer_comp->priv_comp);
-       assert(comp);
+       comp = bt_component_borrow_from_private(muxer_comp->priv_comp);
+       BT_ASSERT(comp);
        count = bt_component_filter_get_input_port_count(comp);
        if (count < 0) {
                BT_LOGD("No input port to initialize for muxer component's notification iterator: "
@@ -1191,20 +1172,18 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
                                muxer_comp->priv_comp, i);
                struct bt_port *port;
 
-               assert(priv_port);
-               port = bt_port_from_private_port(priv_port);
-               assert(port);
+               BT_ASSERT(priv_port);
+               port = bt_port_borrow_from_private(priv_port);
+               BT_ASSERT(port);
 
                if (!bt_port_is_connected(port)) {
                        BT_LOGD("Skipping input port: not connected: "
                                "muxer-comp-addr=%p, port-addr=%p, port-name\"%s\"",
                                muxer_comp, port, bt_port_get_name(port));
                        bt_put(priv_port);
-                       bt_put(port);
                        continue;
                }
 
-               bt_put(port);
                bt_put(priv_port);
                muxer_notif_iter->newly_connected_priv_ports =
                        g_list_append(
@@ -1226,13 +1205,12 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
        }
 
 end:
-       bt_put(comp);
        return ret;
 }
 
 BT_HIDDEN
 enum bt_notification_iterator_status muxer_notif_iter_init(
-               struct bt_private_notification_iterator *priv_notif_iter,
+               struct bt_private_connection_private_notification_iterator *priv_notif_iter,
                struct bt_private_port *output_priv_port)
 {
        struct muxer_comp *muxer_comp = NULL;
@@ -1242,11 +1220,11 @@ enum bt_notification_iterator_status muxer_notif_iter_init(
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
        int ret;
 
-       priv_comp = bt_private_notification_iterator_get_private_component(
+       priv_comp = bt_private_connection_private_notification_iterator_get_private_component(
                priv_notif_iter);
-       assert(priv_comp);
+       BT_ASSERT(priv_comp);
        muxer_comp = bt_private_component_get_user_data(priv_comp);
-       assert(muxer_comp);
+       BT_ASSERT(muxer_comp);
        BT_LOGD("Initializing muxer component's notification iterator: "
                "comp-addr=%p, muxer-comp-addr=%p, notif-iter-addr=%p",
                priv_comp, muxer_comp, priv_notif_iter);
@@ -1299,9 +1277,9 @@ enum bt_notification_iterator_status muxer_notif_iter_init(
                goto error;
        }
 
-       ret = bt_private_notification_iterator_set_user_data(priv_notif_iter,
+       ret = bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter,
                muxer_notif_iter);
-       assert(ret == 0);
+       BT_ASSERT(ret == 0);
        BT_LOGD("Initialized muxer component's notification iterator: "
                "comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, "
                "notif-iter-addr=%p",
@@ -1316,9 +1294,9 @@ error:
        }
 
        destroy_muxer_notif_iter(muxer_notif_iter);
-       ret = bt_private_notification_iterator_set_user_data(priv_notif_iter,
+       ret = bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter,
                NULL);
-       assert(ret == 0);
+       BT_ASSERT(ret == 0);
        status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
 
 end:
@@ -1329,16 +1307,16 @@ end:
 
 BT_HIDDEN
 void muxer_notif_iter_finalize(
-               struct bt_private_notification_iterator *priv_notif_iter)
+               struct bt_private_connection_private_notification_iterator *priv_notif_iter)
 {
        struct muxer_notif_iter *muxer_notif_iter =
-               bt_private_notification_iterator_get_user_data(priv_notif_iter);
+               bt_private_connection_private_notification_iterator_get_user_data(priv_notif_iter);
        struct bt_private_component *priv_comp = NULL;
        struct muxer_comp *muxer_comp = NULL;
 
-       priv_comp = bt_private_notification_iterator_get_private_component(
+       priv_comp = bt_private_connection_private_notification_iterator_get_private_component(
                priv_notif_iter);
-       assert(priv_comp);
+       BT_ASSERT(priv_comp);
        muxer_comp = bt_private_component_get_user_data(priv_comp);
        BT_LOGD("Finalizing muxer component's notification iterator: "
                "comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, "
@@ -1355,21 +1333,21 @@ void muxer_notif_iter_finalize(
 }
 
 BT_HIDDEN
-struct bt_notification_iterator_next_return muxer_notif_iter_next(
-               struct bt_private_notification_iterator *priv_notif_iter)
+struct bt_notification_iterator_next_method_return muxer_notif_iter_next(
+               struct bt_private_connection_private_notification_iterator *priv_notif_iter)
 {
-       struct bt_notification_iterator_next_return next_ret;
+       struct bt_notification_iterator_next_method_return next_ret;
        struct muxer_notif_iter *muxer_notif_iter =
-               bt_private_notification_iterator_get_user_data(priv_notif_iter);
+               bt_private_connection_private_notification_iterator_get_user_data(priv_notif_iter);
        struct bt_private_component *priv_comp = NULL;
        struct muxer_comp *muxer_comp = NULL;
 
-       assert(muxer_notif_iter);
-       priv_comp = bt_private_notification_iterator_get_private_component(
+       BT_ASSERT(muxer_notif_iter);
+       priv_comp = bt_private_connection_private_notification_iterator_get_private_component(
                priv_notif_iter);
-       assert(priv_comp);
+       BT_ASSERT(priv_comp);
        muxer_comp = bt_private_component_get_user_data(priv_comp);
-       assert(muxer_comp);
+       BT_ASSERT(muxer_comp);
 
        BT_LOGV("Muxer component's notification iterator's \"next\" method called: "
                "comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, "
@@ -1413,14 +1391,14 @@ void muxer_port_connected(
                struct bt_port *other_port)
 {
        struct bt_port *self_port =
-               bt_port_from_private_port(self_private_port);
+               bt_port_borrow_from_private(self_private_port);
        struct muxer_comp *muxer_comp =
                bt_private_component_get_user_data(priv_comp);
        size_t i;
        int ret;
 
-       assert(self_port);
-       assert(muxer_comp);
+       BT_ASSERT(self_port);
+       BT_ASSERT(muxer_comp);
        BT_LOGD("Port connected: "
                "comp-addr=%p, muxer-comp-addr=%p, "
                "port-addr=%p, port-name=\"%s\", "
@@ -1478,19 +1456,19 @@ void muxer_port_connected(
        }
 
 end:
-       bt_put(self_port);
+       return;
 }
 
 BT_HIDDEN
 void muxer_port_disconnected(struct bt_private_component *priv_comp,
                struct bt_private_port *priv_port)
 {
-       struct bt_port *port = bt_port_from_private_port(priv_port);
+       struct bt_port *port = bt_port_borrow_from_private(priv_port);
        struct muxer_comp *muxer_comp =
                bt_private_component_get_user_data(priv_comp);
 
-       assert(port);
-       assert(muxer_comp);
+       BT_ASSERT(port);
+       BT_ASSERT(muxer_comp);
        BT_LOGD("Port disconnected: "
                "comp-addr=%p, muxer-comp-addr=%p, port-addr=%p, "
                "port-name=\"%s\"", priv_comp, muxer_comp,
@@ -1516,6 +1494,4 @@ void muxer_port_disconnected(struct bt_private_component *priv_comp,
                        priv_comp, muxer_comp, port, bt_port_get_name(port),
                        muxer_comp->available_input_ports);
        }
-
-       bt_put(port);
 }
This page took 0.03392 seconds and 4 git commands to generate.