lib: rename clock class's absolute property to "origin is Unix epoch"
[babeltrace.git] / plugins / utils / muxer / muxer.c
index 4b3669726cd7c28f99bcccb24809e95fb27ca738..a6a71b7a8ce3283faf27a21ca8e34ef90199a969 100644 (file)
@@ -626,42 +626,81 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
 
        switch (bt_message_get_type(msg)) {
        case BT_MESSAGE_TYPE_EVENT:
+               clock_class =
+                       bt_message_event_borrow_stream_class_default_clock_class_const(
+                               msg);
+               if (!clock_class) {
+                       goto no_clock_snapshot;
+               }
+
                cs_state = bt_message_event_borrow_default_clock_snapshot_const(
                        msg, &clock_snapshot);
                break;
        case BT_MESSAGE_TYPE_PACKET_BEGINNING:
+               bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
+                       msg);
+               if (!clock_class) {
+                       goto no_clock_snapshot;
+               }
+
                cs_state = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
                        msg, &clock_snapshot);
                break;
        case BT_MESSAGE_TYPE_PACKET_END:
+               bt_message_packet_end_borrow_stream_class_default_clock_class_const(
+                       msg);
+               if (!clock_class) {
+                       goto no_clock_snapshot;
+               }
+
                cs_state = bt_message_packet_end_borrow_default_clock_snapshot_const(
                        msg, &clock_snapshot);
                break;
        case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
+               bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
+                       msg);
+               if (!clock_class) {
+                       goto no_clock_snapshot;
+               }
+
                cs_state = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
                        msg, &clock_snapshot);
                break;
        case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
+               bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
+                       msg);
+               if (!clock_class) {
+                       goto no_clock_snapshot;
+               }
+
                cs_state = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const(
                        msg, &clock_snapshot);
                break;
        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
+               bt_message_stream_activity_beginning_borrow_stream_class_default_clock_class_const(
+                       msg);
+               if (!clock_class) {
+                       goto no_clock_snapshot;
+               }
+
                sa_cs_state = bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const(
                        msg, &clock_snapshot);
                if (sa_cs_state != BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN) {
-                       /* No timestamp: high priority */
-                       *ts_ns = last_returned_ts_ns;
-                       goto end;
+                       goto no_clock_snapshot;
                }
 
                break;
        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
+               bt_message_stream_activity_end_borrow_stream_class_default_clock_class_const(
+                       msg);
+               if (!clock_class) {
+                       goto no_clock_snapshot;
+               }
+
                sa_cs_state = bt_message_stream_activity_end_borrow_default_clock_snapshot_const(
                        msg, &clock_snapshot);
                if (sa_cs_state != BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN) {
-                       /* No timestamp: high priority */
-                       *ts_ns = last_returned_ts_ns;
-                       goto end;
+                       goto no_clock_snapshot;
                }
 
                break;
@@ -683,18 +722,6 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
                goto end;
        }
 
-       /*
-        * If the clock snapshot is missing, then we consider that this
-        * message has no time. In this case it's always the
-        * youngest.
-        */
-       if (!clock_snapshot) {
-               BT_LOGV_STR("Message's default clock snapshot is missing: "
-                       "using the last returned timestamp.");
-               *ts_ns = last_returned_ts_ns;
-               goto end;
-       }
-
        clock_class = bt_clock_snapshot_borrow_clock_class_const(clock_snapshot);
        BT_ASSERT(clock_class);
        cc_uuid = bt_clock_class_get_uuid(clock_class);
@@ -709,7 +736,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
                 * the iterator without a true
                 * `assume-absolute-clock-classes` parameter.
                 */
-               if (bt_clock_class_is_absolute(clock_class)) {
+               if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
                        /* Expect absolute clock classes */
                        muxer_msg_iter->clock_class_expectation =
                                MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE;
@@ -737,7 +764,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
        if (!muxer_comp->assume_absolute_clock_classes) {
                switch (muxer_msg_iter->clock_class_expectation) {
                case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE:
-                       if (!bt_clock_class_is_absolute(clock_class)) {
+                       if (!bt_clock_class_origin_is_unix_epoch(clock_class)) {
                                BT_LOGE("Expecting an absolute clock class, "
                                        "but got a non-absolute one: "
                                        "clock-class-addr=%p, clock-class-name=\"%s\"",
@@ -746,7 +773,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
                        }
                        break;
                case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID:
-                       if (bt_clock_class_is_absolute(clock_class)) {
+                       if (bt_clock_class_origin_is_unix_epoch(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\"",
@@ -780,7 +807,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
                        }
                        break;
                case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID:
-                       if (bt_clock_class_is_absolute(clock_class)) {
+                       if (bt_clock_class_origin_is_unix_epoch(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\"",
@@ -857,6 +884,12 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
 
        goto end;
 
+no_clock_snapshot:
+       BT_LOGV_STR("Message's default clock snapshot is missing: "
+               "using the last returned timestamp.");
+       *ts_ns = last_returned_ts_ns;
+       goto end;
+
 error:
        ret = -1;
 
This page took 0.024965 seconds and 4 git commands to generate.