mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
gsttracer: Add new API to fetch the list of active tracers
This will be useful in the next commit where we add action-signals on the leaks tracer to get information about leaks and to manipulate checkpoints as a replacement for the SIGUSR1 and SIGUSR2 signals for doing the same.
This commit is contained in:
parent
5cdf1b7db8
commit
1685f38bb2
2 changed files with 41 additions and 0 deletions
|
@ -74,6 +74,9 @@ void gst_tracing_register_hook (GstTracer *tracer, const gchar *detail,
|
|||
GST_API
|
||||
gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
|
||||
|
||||
GST_API
|
||||
GList* gst_tracing_get_active_tracers (void);
|
||||
|
||||
#endif
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstTracer, gst_object_unref)
|
||||
|
|
|
@ -205,3 +205,41 @@ gst_tracing_register_hook (GstTracer * tracer, const gchar * detail,
|
|||
}
|
||||
|
||||
#endif /* GST_DISABLE_GST_TRACER_HOOKS */
|
||||
|
||||
/**
|
||||
* gst_tracing_get_active_tracers:
|
||||
*
|
||||
* Get a list of all active tracer objects owned by the tracing framework for
|
||||
* the entirety of the run-time of the process or till gst_deinit() is called.
|
||||
*
|
||||
* Returns: (transfer full) (element-type Gst.Tracer): A #GList of
|
||||
* #GstTracer objects
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
GList *
|
||||
gst_tracing_get_active_tracers (void)
|
||||
{
|
||||
GList *tracers, *h_list, *h_node, *t_node;
|
||||
GstTracerHook *hook;
|
||||
|
||||
if (!_priv_tracer_enabled || !_priv_tracers)
|
||||
return NULL;
|
||||
|
||||
tracers = NULL;
|
||||
h_list = g_hash_table_get_values (_priv_tracers);
|
||||
for (h_node = h_list; h_node; h_node = g_list_next (h_node)) {
|
||||
for (t_node = h_node->data; t_node; t_node = g_list_next (t_node)) {
|
||||
hook = (GstTracerHook *) t_node->data;
|
||||
/* Skip duplicate tracers from different hooks. This function is O(n), but
|
||||
* that should be fine since the number of tracers enabled on a process
|
||||
* should be small. */
|
||||
if (g_list_index (tracers, hook->tracer) >= 0)
|
||||
continue;
|
||||
tracers = g_list_prepend (tracers, gst_object_ref (hook->tracer));
|
||||
}
|
||||
}
|
||||
g_list_free (h_list);
|
||||
|
||||
return tracers;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue