- struct bt_stream *stream = NULL;
- struct bt_trace *trace = NULL;
-
- BT_LOGD("Creating stream object: stream-class-addr=%p, "
- "stream-class-name=\"%s\", stream-name=\"%s\", "
- "stream-id=%" PRIu64,
- stream_class, bt_stream_class_get_name(stream_class),
- name, id);
-
- trace = bt_stream_class_borrow_trace(stream_class);
- if (!trace) {
- BT_LOGW("Invalid parameter: cannot create stream from a stream class which is not part of trace: "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-name=\"%s\"",
- stream_class, bt_stream_class_get_name(stream_class),
- name);
- goto error;
- }
-
- if (bt_trace_is_static(trace)) {
- /*
- * A static trace has the property that all its stream
- * classes, clock classes, and streams are definitive:
- * no more can be added, and each object is also frozen.
- */
- BT_LOGW("Invalid parameter: cannot create stream from a stream class which is part of a static trace: "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-name=\"%s\", trace-addr=%p",
- stream_class, bt_stream_class_get_name(stream_class),
- name, trace);
- goto error;
- }
-
+ struct bt_stream *stream;
+ struct bt_trace *trace;
+
+ BT_ASSERT(stream_class);
+ trace = bt_stream_class_borrow_trace_inline(stream_class);
+ BT_ASSERT_PRE(stream_id_is_unique(trace, stream_class, id),
+ "Duplicate stream ID: %![trace-]+t, id=%" PRIu64, trace, id);
+ BT_ASSERT_PRE(!trace->is_static,
+ "Trace is static: %![trace-]+t", trace);
+ BT_LIB_LOGD("Creating stream object: %![trace-]+t, id=%" PRIu64,
+ trace, id);