src.ctf.fs: make create_streams_for_trace use bt2::StreamClass to instantiate streams
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Jul 2022 21:31:20 +0000 (17:31 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -0400)
Wrap the stream class (ds_file_group->sc->ir_sc) in a bt2::StreamClass,
then use that to instantiate streams.

Change-Id: I9e9917dd96b0d1115b443463a0a2cd8f2da42323
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8437
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/fs-src/fs.cpp

index ec21795aa07abdba44ce8c7e2d6e00f73b9dfca2..fc0d7140dc9d66fcc285200d72910b3d6f99a155 100644 (file)
@@ -1488,30 +1488,18 @@ static int create_streams_for_trace(struct ctf_fs_trace *ctf_fs_trace)
         BT_ASSERT(ds_file_group->sc->ir_sc);
         BT_ASSERT(ctf_fs_trace->trace);
 
-        bt_stream *stream;
+        bt2::StreamClass sc {ds_file_group->sc->ir_sc};
 
         if (ds_file_group->stream_id == UINT64_C(-1)) {
             /* No stream ID: use 0 */
-            stream = bt_stream_create_with_id(ds_file_group->sc->ir_sc,
-                                              (*ctf_fs_trace->trace)->libObjPtr(),
-                                              ctf_fs_trace->next_stream_id);
+            ds_file_group->stream =
+                sc.instantiate(**ctf_fs_trace->trace, ctf_fs_trace->next_stream_id);
             ctf_fs_trace->next_stream_id++;
         } else {
             /* Specific stream ID */
-            stream = bt_stream_create_with_id(ds_file_group->sc->ir_sc,
-                                              (*ctf_fs_trace->trace)->libObjPtr(),
-                                              (uint64_t) ds_file_group->stream_id);
+            ds_file_group->stream = sc.instantiate(**ctf_fs_trace->trace, ds_file_group->stream_id);
         }
 
-        if (!stream) {
-            BT_CLOGE_APPEND_CAUSE("Cannot create stream for DS file group: "
-                                  "addr=%p, stream-name=\"%s\"",
-                                  ds_file_group.get(), name.c_str());
-            return -1;
-        }
-
-        ds_file_group->stream = bt2::Stream::Shared::createWithoutRef(stream);
-
         int ret = bt_stream_set_name((*ds_file_group->stream)->libObjPtr(), name.c_str());
         if (ret) {
             BT_CLOGE_APPEND_CAUSE("Cannot set stream's name: "
This page took 0.026757 seconds and 5 git commands to generate.