struct bt_message_packet *message = NULL;
struct bt_stream *stream;
struct bt_stream_class *stream_class;
+ bool packet_has_default_clock_snapshot;
BT_ASSERT(msg_iter);
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
BT_ASSERT(stream);
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
- BT_ASSERT_PRE((with_cs && stream_class->default_clock_class) ||
- (!with_cs && !stream_class->default_clock_class),
- "Creating a packet message with a default clock snapshot, but without "
- "a default clock class, or without a default clock snapshot, "
- "but with a default clock class: ",
+
+ if (pool == &msg_iter->graph->packet_begin_msg_pool) {
+ packet_has_default_clock_snapshot =
+ stream_class->packets_have_beginning_default_clock_snapshot;
+ } else {
+ packet_has_default_clock_snapshot =
+ stream_class->packets_have_end_default_clock_snapshot;
+ }
+
+ /*
+ * `packet_has_default_clock_snapshot` implies that the stream
+ * class has a default clock class (precondition).
+ */
+ BT_ASSERT_PRE((with_cs && packet_has_default_clock_snapshot) ||
+ (!with_cs && !packet_has_default_clock_snapshot),
+ "Unexpected stream class configuration when creating "
+ "a packet beginning or end message: ",
"%![stream-]+s, %![sc-]+S, with-cs=%d, "
"cs-val=%" PRIu64,
stream, stream_class, with_cs, raw_value);
}
static inline
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
borrow_packet_message_default_clock_snapshot_const(
- const struct bt_message *message,
- const struct bt_clock_snapshot **snapshot)
+ const struct bt_message *message)
{
struct bt_message_packet *packet_msg = (void *) message;
"Message's stream's class has no default clock class: "
"%![msg-]+n, %![sc-]+S",
message, packet_msg->packet->stream->class);
- BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
- *snapshot = packet_msg->default_cs;
- return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
+ return packet_msg->default_cs;
}
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
bt_message_packet_beginning_borrow_default_clock_snapshot_const(
- const struct bt_message *msg,
- const struct bt_clock_snapshot **snapshot)
+ const struct bt_message *msg)
{
BT_ASSERT_PRE_NON_NULL(msg, "Message");
BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING);
- return borrow_packet_message_default_clock_snapshot_const(
- msg, snapshot);
+ return borrow_packet_message_default_clock_snapshot_const(msg);
}
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
bt_message_packet_end_borrow_default_clock_snapshot_const(
- const struct bt_message *msg,
- const struct bt_clock_snapshot **snapshot)
+ const struct bt_message *msg)
{
BT_ASSERT_PRE_NON_NULL(msg, "Message");
BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END);
- return borrow_packet_message_default_clock_snapshot_const(
- msg, snapshot);
+ return borrow_packet_message_default_clock_snapshot_const(msg);
}
static inline