/*
* stream.c
*
- * Babeltrace CTF Writer
+ * Babeltrace CTF IR - Stream
*
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
goto error_destroy;
}
- /* Initialize events_discarded*/
+ /*
+ * A stream class may not have a stream event context defined
+ * in which case this stream will never have a stream_event_context
+ * member since, after a stream's creation, the parent stream class
+ * is "frozen" (immutable).
+ */
+ if (stream_class->event_context_type) {
+ stream->event_context = bt_ctf_field_create(
+ stream_class->event_context_type);
+ if (!stream->packet_context) {
+ goto error_destroy;
+ }
+ }
+
ret = set_structure_field_integer(stream->packet_context,
"events_discarded", 0);
if (ret) {
{
int ret = 0;
uint64_t timestamp;
+ struct bt_ctf_field *event_context_copy = NULL;
if (!stream || !event) {
ret = -1;
struct bt_ctf_field *integer = NULL;
struct ctf_stream_pos packet_context_pos;
- if (!stream) {
+ if (!stream || stream->pos.fd < 0) {
+ /*
+ * Stream does not have an associated fd. It is,
+ * therefore, not a stream being used to write events.
+ */
ret = -1;
goto end;
}