mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-28 23:02:22 +00:00
tracers: Allow setting a name for all tracer objects
This will be useful in combination with the next commit when we add API to get a list of active tracers so that consumers of the API can easily distinguish tracer objects.
This commit is contained in:
parent
8a9b20a18b
commit
5cdf1b7db8
5 changed files with 107 additions and 5 deletions
|
@ -508,9 +508,15 @@ gst_latency_tracer_constructed (GObject * object)
|
||||||
params_struct = gst_structure_from_string (tmp, NULL);
|
params_struct = gst_structure_from_string (tmp, NULL);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
|
||||||
/* Read the flags if available */
|
|
||||||
if (params_struct) {
|
if (params_struct) {
|
||||||
const gchar *flags = gst_structure_get_string (params_struct, "flags");
|
const gchar *name, *flags;
|
||||||
|
/* Set the name if assigned */
|
||||||
|
name = gst_structure_get_string (params_struct, "name");
|
||||||
|
if (name)
|
||||||
|
gst_object_set_name (GST_OBJECT (self), name);
|
||||||
|
|
||||||
|
/* Read the flags if available */
|
||||||
|
flags = gst_structure_get_string (params_struct, "flags");
|
||||||
|
|
||||||
self->flags = 0;
|
self->flags = 0;
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,19 @@
|
||||||
* active at the same time.
|
* active at the same time.
|
||||||
*
|
*
|
||||||
* Parameters can also be passed to each tracer. The leaks tracer currently
|
* Parameters can also be passed to each tracer. The leaks tracer currently
|
||||||
* accepts three params:
|
* accepts four params:
|
||||||
* 1. filters: to filter which objects to record
|
* 1. filters: to filter which objects to record
|
||||||
* 2. check-refs: whether to record every location where a leaked object was
|
* 2. check-refs: whether to record every location where a leaked object was
|
||||||
* reffed and unreffed
|
* reffed and unreffed
|
||||||
* 3. stack-traces-flags: full or none; see: #GstStackTraceFlags
|
* 3. stack-traces-flags: full or none; see: #GstStackTraceFlags
|
||||||
|
* 4. name: set a name for the tracer object itself
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* ```
|
* ```
|
||||||
* GST_TRACERS=leaks(filters="GstEvent,GstMessage",stack-traces-flags=full)
|
* GST_TRACERS='leaks(filters="GstEvent,GstMessage",stack-traces-flags=none)'
|
||||||
|
* ```
|
||||||
|
* ```
|
||||||
|
* GST_TRACERS='leaks(filters="GstBuffer",stack-traces-flags=full,check-refs=true);leaks(name=all-leaks)'
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -176,10 +180,16 @@ set_filters (GstLeaksTracer * self, const gchar * filters)
|
||||||
static void
|
static void
|
||||||
set_params_from_structure (GstLeaksTracer * self, GstStructure * params)
|
set_params_from_structure (GstLeaksTracer * self, GstStructure * params)
|
||||||
{
|
{
|
||||||
const gchar *filters = gst_structure_get_string (params, "filters");
|
const gchar *filters, *name;
|
||||||
|
|
||||||
|
filters = gst_structure_get_string (params, "filters");
|
||||||
if (filters)
|
if (filters)
|
||||||
set_filters (self, filters);
|
set_filters (self, filters);
|
||||||
|
|
||||||
|
name = gst_structure_get_string (params, "name");
|
||||||
|
if (name)
|
||||||
|
gst_object_set_name (GST_OBJECT (self), name);
|
||||||
|
|
||||||
gst_structure_get_boolean (params, "check-refs", &self->check_refs);
|
gst_structure_get_boolean (params, "check-refs", &self->check_refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,9 +309,38 @@ do_pad_unlink_post (GstTracer * self, guint64 ts, GstPad * src,
|
||||||
|
|
||||||
/* tracer class */
|
/* tracer class */
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_log_tracer_constructed (GObject * object)
|
||||||
|
{
|
||||||
|
GstLogTracer *self = GST_LOG_TRACER (object);
|
||||||
|
gchar *params, *tmp;
|
||||||
|
const gchar *name;
|
||||||
|
GstStructure *params_struct = NULL;
|
||||||
|
|
||||||
|
g_object_get (self, "params", ¶ms, NULL);
|
||||||
|
|
||||||
|
if (!params)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tmp = g_strdup_printf ("log,%s", params);
|
||||||
|
params_struct = gst_structure_from_string (tmp, NULL);
|
||||||
|
g_free (tmp);
|
||||||
|
if (!params_struct)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Set the name if assigned */
|
||||||
|
name = gst_structure_get_string (params_struct, "name");
|
||||||
|
if (name)
|
||||||
|
gst_object_set_name (GST_OBJECT (self), name);
|
||||||
|
gst_structure_free (params_struct);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_log_tracer_class_init (GstLogTracerClass * klass)
|
gst_log_tracer_class_init (GstLogTracerClass * klass)
|
||||||
{
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->constructed = gst_log_tracer_constructed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -256,6 +256,32 @@ do_stats (GstTracer * obj, guint64 ts)
|
||||||
|
|
||||||
/* tracer class */
|
/* tracer class */
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_rusage_tracer_constructed (GObject * object)
|
||||||
|
{
|
||||||
|
GstRUsageTracer *self = GST_RUSAGE_TRACER (object);
|
||||||
|
gchar *params, *tmp;
|
||||||
|
const gchar *name;
|
||||||
|
GstStructure *params_struct = NULL;
|
||||||
|
|
||||||
|
g_object_get (self, "params", ¶ms, NULL);
|
||||||
|
|
||||||
|
if (!params)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tmp = g_strdup_printf ("rusage,%s", params);
|
||||||
|
params_struct = gst_structure_from_string (tmp, NULL);
|
||||||
|
g_free (tmp);
|
||||||
|
if (!params_struct)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Set the name if assigned */
|
||||||
|
name = gst_structure_get_string (params_struct, "name");
|
||||||
|
if (name)
|
||||||
|
gst_object_set_name (GST_OBJECT (self), name);
|
||||||
|
gst_structure_free (params_struct);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rusage_tracer_finalize (GObject * obj)
|
gst_rusage_tracer_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
|
@ -272,6 +298,7 @@ gst_rusage_tracer_class_init (GstRUsageTracerClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->constructed = gst_rusage_tracer_constructed;
|
||||||
gobject_class->finalize = gst_rusage_tracer_finalize;
|
gobject_class->finalize = gst_rusage_tracer_finalize;
|
||||||
|
|
||||||
if ((num_cpus = sysconf (_SC_NPROCESSORS_ONLN)) == -1) {
|
if ((num_cpus = sysconf (_SC_NPROCESSORS_ONLN)) == -1) {
|
||||||
|
|
|
@ -520,9 +520,39 @@ do_query_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
||||||
|
|
||||||
/* tracer class */
|
/* tracer class */
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_stats_tracer_constructed (GObject * object)
|
||||||
|
{
|
||||||
|
GstStatsTracer *self = GST_STATS_TRACER (object);
|
||||||
|
gchar *params, *tmp;
|
||||||
|
const gchar *name;
|
||||||
|
GstStructure *params_struct = NULL;
|
||||||
|
|
||||||
|
g_object_get (self, "params", ¶ms, NULL);
|
||||||
|
|
||||||
|
if (!params)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tmp = g_strdup_printf ("stats,%s", params);
|
||||||
|
params_struct = gst_structure_from_string (tmp, NULL);
|
||||||
|
g_free (tmp);
|
||||||
|
if (!params_struct)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Set the name if assigned */
|
||||||
|
name = gst_structure_get_string (params_struct, "name");
|
||||||
|
if (name)
|
||||||
|
gst_object_set_name (GST_OBJECT (self), name);
|
||||||
|
gst_structure_free (params_struct);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_stats_tracer_class_init (GstStatsTracerClass * klass)
|
gst_stats_tracer_class_init (GstStatsTracerClass * klass)
|
||||||
{
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->constructed = gst_stats_tracer_constructed;
|
||||||
|
|
||||||
/* announce trace formats */
|
/* announce trace formats */
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
tr_buffer = gst_tracer_record_new ("buffer.class",
|
tr_buffer = gst_tracer_record_new ("buffer.class",
|
||||||
|
|
Loading…
Reference in a new issue