- ret = bt_event_set_clock_value(event, clock_value);
- bt_put(clock_value);
- if (ret) {
- struct bt_event_class *event_class =
- bt_event_borrow_class(event);
-
- BT_ASSERT(event_class);
- BT_LOGE("Cannot set event's clock value: "
- "notit-addr=%p, event-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", "
- "clock-class-addr=%p, "
- "clock-class-name=\"%s\", "
- "clock-value-addr=%p",
- notit, event,
- bt_event_class_get_name(event_class),
- bt_event_class_get_id(event_class),
- clock_class,
- bt_clock_class_get_name(clock_class),
- clock_value);
- goto end;
- }
- }
-
- ret = 0;
-end:
- return ret;
-}
-
-static
-struct bt_event *create_event(struct bt_notif_iter *notit)
-{
- int ret;
- struct bt_event *event;
-
- BT_LOGV("Creating event for event notification: "
- "notit-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64,
- notit, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class));
-
- /* Create event object. */
- event = bt_event_create(notit->meta.event_class);
- if (!event) {
- BT_LOGE("Cannot create event: "
- "notit-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64,
- notit, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class));
- goto error;
- }
-
- /* Set header, stream event context, context, and payload fields. */
- ret = bt_event_set_header(event,
- notit->dscopes.stream_event_header);
- if (ret) {
- BT_LOGE("Cannot set event's header field: "
- "notit-addr=%p, event-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", field-addr=%p",
- notit, event, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class),
- notit->dscopes.stream_event_header);
- goto error;
- }
-
- ret = bt_event_set_stream_event_context(event,
- notit->dscopes.stream_event_context);
- if (ret) {
- BT_LOGE("Cannot set event's context field: "
- "notit-addr=%p, event-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", field-addr=%p",
- notit, event, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class),
- notit->dscopes.stream_event_context);
- goto error;
- }
-
- ret = bt_event_set_context(event,
- notit->dscopes.event_context);
- if (ret) {
- BT_LOGE("Cannot set event's stream event context field: "
- "notit-addr=%p, event-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", field-addr=%p",
- notit, event, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class),
- notit->dscopes.event_context);
- goto error;
- }
-
- ret = bt_event_set_payload(event,
- notit->dscopes.event_payload);
- if (ret) {
- BT_LOGE("Cannot set event's payload field: "
- "notit-addr=%p, event-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", field-addr=%p",
- notit, event, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class),
- notit->dscopes.event_payload);
- goto error;
- }
-
- ret = set_event_clocks(event, notit);
- if (ret) {
- BT_LOGE("Cannot set event's clock values: "
- "notit-addr=%p, event-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64,
- notit, event, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class));
- goto error;
- }
-
- /* Associate with current packet. */
- BT_ASSERT(notit->packet);
- ret = bt_event_set_packet(event, notit->packet);
- if (ret) {
- BT_LOGE("Cannot set event's header field: "
- "notit-addr=%p, event-addr=%p, event-class-addr=%p, "
- "event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", packet-addr=%p",
- notit, event, notit->meta.event_class,
- bt_event_class_get_name(notit->meta.event_class),
- bt_event_class_get_id(notit->meta.event_class),
- notit->packet);
- goto error;
- }
-
- goto end;
-
-error:
- BT_PUT(event);
-
-end:
- return event;
-}
-
-static
-uint64_t get_cur_stream_instance_id(struct bt_notif_iter *notit)
-{
- struct bt_field *stream_instance_id_field = NULL;
- uint64_t stream_instance_id = -1ULL;
- int ret;
-
- if (!notit->dscopes.trace_packet_header) {
- goto end;
- }
-
- stream_instance_id_field = bt_field_structure_get_field_by_name(
- notit->dscopes.trace_packet_header, "stream_instance_id");
- if (!stream_instance_id_field) {
- goto end;
- }
-
- ret = bt_field_integer_unsigned_get_value(stream_instance_id_field,
- &stream_instance_id);
- if (ret) {
- stream_instance_id = -1ULL;
- goto end;
- }
-
-end:
- bt_put(stream_instance_id_field);
- return stream_instance_id;
-}
-
-static
-int set_stream(struct bt_notif_iter *notit)
-{
- int ret = 0;
- struct bt_stream *stream = NULL;
-
- BT_LOGV("Calling user function (get stream): notit-addr=%p, "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64,
- notit, notit->meta.stream_class,
- bt_stream_class_get_name(notit->meta.stream_class),
- bt_stream_class_get_id(notit->meta.stream_class));
- stream = bt_get(notit->medium.medops.get_stream(
- notit->meta.stream_class, get_cur_stream_instance_id(notit),
- notit->medium.data));
- BT_LOGV("User function returned: stream-addr=%p", stream);
- if (!stream) {
- BT_LOGW_STR("User function failed to return a stream object for the given stream class.");
- ret = -1;
- goto end;
- }