Skip to content

Commit

Permalink
Ensure CTF structure is used after correct CTF initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgruner committed Oct 26, 2022
1 parent 7dccd22 commit 8b32174
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 38 deletions.
11 changes: 5 additions & 6 deletions plugins/tracers/gstbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ gst_buffer_buffer_list_pre (GObject * self, GstClockTime ts, GstPad * pad,
static void
gst_buffer_tracer_class_init (GstBufferTracerClass * klass)
{
gchar *metadata_event;

tr_buffer = gst_tracer_record_new ("buffer.class",
"pad", GST_TYPE_STRUCTURE, gst_structure_new ("value",
"type", G_TYPE_GTYPE, G_TYPE_STRING,
Expand Down Expand Up @@ -178,16 +176,13 @@ gst_buffer_tracer_class_init (GstBufferTracerClass * klass)
GST_TYPE_STRUCTURE, gst_structure_new ("value", "type", G_TYPE_GTYPE,
G_TYPE_UINT, "description", G_TYPE_STRING, "Ref Count", "min",
G_TYPE_UINT, 0, "max", G_TYPE_UINT, G_MAXUINT32, NULL), NULL);

metadata_event = g_strdup_printf (buffer_metadata_event, BUFFER_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}

static void
gst_buffer_tracer_init (GstBufferTracer * self)
{
GstSharkTracer *tracer = GST_SHARK_TRACER (self);
gchar *metadata_event = NULL;

gst_shark_tracer_register_hook (tracer, "pad-push-pre",
G_CALLBACK (gst_buffer_buffer_pre));
Expand All @@ -197,4 +192,8 @@ gst_buffer_tracer_init (GstBufferTracer * self)

gst_shark_tracer_register_hook (tracer, "pad-pull-range-post",
G_CALLBACK (gst_buffer_range_post));

metadata_event = g_strdup_printf (buffer_metadata_event, BUFFER_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}
12 changes: 6 additions & 6 deletions plugins/tracers/gstinterlatency.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ static void
gst_interlatency_tracer_class_init (GstInterLatencyTracerClass * klass)
{
GObjectClass *oclass;
gchar *metadata_event;

oclass = G_OBJECT_CLASS (klass);

Expand Down Expand Up @@ -312,17 +311,13 @@ gst_interlatency_tracer_class_init (GstInterLatencyTracerClass * klass)
/* *INDENT-ON* */

oclass->dispose = gst_interlatency_tracer_dispose;

metadata_event =
g_strdup_printf (interlatency_metadata_event, INTERLATENCY_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}

static void
gst_interlatency_tracer_init (GstInterLatencyTracer * self)
{
GstTracer *tracer = GST_TRACER (self);
gchar *metadata_event = NULL;

/* In push mode, pre/post will be called before/after the peer chain
* function has been called. For this reason, we only use -pre to avoid
Expand All @@ -344,6 +339,11 @@ gst_interlatency_tracer_init (GstInterLatencyTracer * self)
G_CALLBACK (do_pull_range_post));
gst_tracing_register_hook (tracer, "pad-push-event-pre",
G_CALLBACK (do_push_event_pre));

metadata_event =
g_strdup_printf (interlatency_metadata_event, INTERLATENCY_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}

static void
Expand Down
14 changes: 7 additions & 7 deletions plugins/tracers/gstproctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static void
gst_proc_time_tracer_class_init (GstProcTimeTracerClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gchar *metadata_event;


gobject_class->finalize = gst_proc_time_tracer_finalize;

Expand All @@ -147,19 +147,14 @@ gst_proc_time_tracer_class_init (GstProcTimeTracerClass * klass)
gst_structure_new ("scope", "type", G_TYPE_GTYPE, G_TYPE_STRING,
"related-to", GST_TYPE_TRACER_VALUE_SCOPE,
GST_TRACER_VALUE_SCOPE_PROCESS, NULL), NULL);

metadata_event =
g_strdup_printf (proc_time_metadata_event, PROCTIME_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}


static void
gst_proc_time_tracer_init (GstProcTimeTracer * self)
{
GstTracer *tracer = GST_TRACER (self);

gchar *metadata_event = NULL;

self->proc_time = gst_proctime_new ();

Expand All @@ -168,4 +163,9 @@ gst_proc_time_tracer_init (GstProcTimeTracer * self)

gst_tracing_register_hook (tracer, "element-new",
G_CALLBACK (do_element_new));

metadata_event =
g_strdup_printf (proc_time_metadata_event, PROCTIME_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}
13 changes: 6 additions & 7 deletions plugins/tracers/gstqueuelevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ is_queue (GstElement * element)
static void
gst_queue_level_tracer_class_init (GstQueueLevelTracerClass * klass)
{
gchar *metadata_event;

tr_qlevel = gst_tracer_record_new ("queuelevel.class", "queue",
GST_TYPE_STRUCTURE, gst_structure_new ("scope",
"type", G_TYPE_GTYPE, G_TYPE_STRING,
Expand Down Expand Up @@ -201,17 +199,13 @@ gst_queue_level_tracer_class_init (GstQueueLevelTracerClass * klass)
"type", G_TYPE_GTYPE, G_TYPE_STRING,
"related-to", GST_TYPE_TRACER_VALUE_SCOPE,
GST_TRACER_VALUE_SCOPE_ELEMENT, NULL), NULL);

metadata_event =
g_strdup_printf (queue_level_metadata_event, QUEUE_LEVEL_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}

static void
gst_queue_level_tracer_init (GstQueueLevelTracer * self)
{
GstSharkTracer *tracer = GST_SHARK_TRACER (self);
gchar *metadata_event = NULL;

gst_shark_tracer_register_hook (tracer, "pad-push-pre",
G_CALLBACK (do_queue_level));
Expand All @@ -221,4 +215,9 @@ gst_queue_level_tracer_init (GstQueueLevelTracer * self)

gst_shark_tracer_register_hook (tracer, "pad-pull-range-pre",
G_CALLBACK (do_queue_level));

metadata_event =
g_strdup_printf (queue_level_metadata_event, QUEUE_LEVEL_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}
12 changes: 6 additions & 6 deletions plugins/tracers/gstscheduletime.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ static void
gst_scheduletime_tracer_class_init (GstScheduletimeTracerClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gchar *metadata_event;

gobject_class->finalize = gst_scheduletime_tracer_finalize;

Expand All @@ -168,17 +167,13 @@ gst_scheduletime_tracer_class_init (GstScheduletimeTracerClass * klass)
"type", G_TYPE_GTYPE, G_TYPE_STRING,
"related-to", GST_TYPE_TRACER_VALUE_SCOPE,
GST_TRACER_VALUE_SCOPE_PROCESS, NULL), NULL);

metadata_event =
g_strdup_printf (scheduling_metadata_event, SCHED_TIME_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}

static void
gst_scheduletime_tracer_init (GstScheduletimeTracer * self)
{
GstSharkTracer *tracer = GST_SHARK_TRACER (self);
gchar *metadata_event = NULL;

self->schedule_pads =
g_hash_table_new_full (g_direct_hash, g_direct_equal, key_destroy,
Expand All @@ -192,4 +187,9 @@ gst_scheduletime_tracer_init (GstScheduletimeTracer * self)

gst_shark_tracer_register_hook (tracer, "pad-pull-range-pre",
G_CALLBACK (sched_time_compute));

metadata_event =
g_strdup_printf (scheduling_metadata_event, SCHED_TIME_EVENT_ID, 0);
add_metadata_event_struct (metadata_event);
g_free (metadata_event);
}
13 changes: 7 additions & 6 deletions plugins/tracers/gstsharktracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@ static void
gst_shark_tracer_init (GstSharkTracer * self)
{
GstSharkTracerPrivate *priv = GST_SHARK_TRACER_PRIVATE (self);
gint prev_count = 0;

priv->params = g_hash_table_new (g_str_hash, g_str_equal);
priv->hooks = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
priv->myhooks = g_hash_table_new (g_str_hash, g_str_equal);

gst_shark_tracer_fill_hooks (priv);

prev_count = g_atomic_int_add (&g_shark_tracer_refcount, 1);
if (prev_count == 0) {
gst_ctf_init ();
}
}

static void
Expand Down Expand Up @@ -223,15 +229,10 @@ gst_shark_tracer_fill_hooks (GstSharkTracerPrivate * priv)
static void
gst_shark_tracer_constructed (GObject * object)
{
gint prev_count;

GstSharkTracer *self = GST_SHARK_TRACER (object);

gst_shark_tracer_save_params (self);

prev_count = g_atomic_int_add (&g_shark_tracer_refcount, 1);
if (prev_count == 0) {
gst_ctf_init ();
}
}

static void
Expand Down

0 comments on commit 8b32174

Please sign in to comment.