X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgsttracerutils.c;h=2522cbf91c37af714d06cf3e3ca783fb6c1de275;hb=a143d9cb0caee85bbe0c5e8b86e9f05918153c9d;hp=9e322edc7022d8de8a5f673fed93f708f1142dc9;hpb=63421675b196c10996bf2ebb4507f6309afeca53;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gsttracerutils.c b/gst/gsttracerutils.c index 9e322ed..2522cbf 100644 --- a/gst/gsttracerutils.c +++ b/gst/gsttracerutils.c @@ -19,15 +19,16 @@ * Boston, MA 02110-1301, USA. */ -/** - * SECTION:gsttracerutils - * @short_description: Tracing subsystem +/* Tracing subsystem: * * The tracing subsystem provides hooks in the core library and API for modules * to attach to them. * * The user can activate tracers by setting the environment variable GST_TRACE * to a ';' separated list of tracers. + * + * Note that instantiating tracers at runtime is possible but is not thread safe + * and needs to be done before any pipeline state is set to PAUSED. */ #define GST_USE_UNSTABLE_API @@ -52,7 +53,10 @@ static const gchar *_quark_strings[] = { "element-new", "element-add-pad", "element-remove-pad", "bin-add-pre", "bin-add-post", "bin-remove-pre", "bin-remove-post", "pad-link-pre", "pad-link-post", "pad-unlink-pre", "pad-unlink-post", - "element-change-state-pre", "element-change-state-post" + "element-change-state-pre", "element-change-state-post", + "mini-object-created", "mini-object-destroyed", "object-created", + "object-destroyed", "mini-object-reffed", "mini-object-unreffed", + "object-reffed", "object-unreffed", }; GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX]; @@ -66,29 +70,32 @@ GHashTable *_priv_tracers = NULL; void _priv_gst_tracing_init (void) { + gint i = 0; const gchar *env = g_getenv ("GST_TRACERS"); + /* We initialize the tracer sub system even if the end + * user did not activate it through the env variable + * so that external tools can use it anyway */ + GST_DEBUG ("Initializing GstTracer"); + _priv_tracers = g_hash_table_new (NULL, NULL); + + if (G_N_ELEMENTS (_quark_strings) != GST_TRACER_QUARK_MAX) + g_warning ("the quark table is not consistent! %d != %d", + (gint) G_N_ELEMENTS (_quark_strings), GST_TRACER_QUARK_MAX); + + for (i = 0; i < GST_TRACER_QUARK_MAX; i++) { + _priv_gst_tracer_quark_table[i] = + g_quark_from_static_string (_quark_strings[i]); + } + if (env != NULL && *env != '\0') { GstRegistry *registry = gst_registry_get (); GstPluginFeature *feature; GstTracerFactory *factory; gchar **t = g_strsplit_set (env, ";", 0); - gint i = 0; gchar *params; GST_INFO ("enabling tracers: '%s'", env); - - if (G_N_ELEMENTS (_quark_strings) != GST_TRACER_QUARK_MAX) - g_warning ("the quark table is not consistent! %d != %d", - (gint) G_N_ELEMENTS (_quark_strings), GST_TRACER_QUARK_MAX); - - for (i = 0; i < GST_TRACER_QUARK_MAX; i++) { - _priv_gst_tracer_quark_table[i] = - g_quark_from_static_string (_quark_strings[i]); - } - - _priv_tracers = g_hash_table_new (NULL, NULL); - i = 0; while (t[i]) { // check t[i] for params @@ -107,12 +114,18 @@ _priv_gst_tracing_init (void) if ((feature = gst_registry_lookup_feature (registry, t[i]))) { factory = GST_TRACER_FACTORY (gst_plugin_feature_load (feature)); if (factory) { + GstTracer *tracer; + GST_INFO_OBJECT (factory, "creating tracer: type-id=%u", (guint) factory->type); + tracer = g_object_new (factory->type, "params", params, NULL); + + /* Clear floating flag */ + gst_object_ref_sink (tracer); + /* tracers register them self to the hooks */ - gst_object_unref (g_object_new (factory->type, "params", params, - NULL)); + gst_object_unref (tracer); } else { GST_WARNING_OBJECT (feature, "loading plugin containing feature %s failed!", t[i]); @@ -183,4 +196,12 @@ gst_tracing_register_hook (GstTracer * tracer, const gchar * detail, gst_tracing_register_hook_id (tracer, g_quark_try_string (detail), func); } +#else /* !GST_DISABLE_GST_TRACER_HOOKS */ + +void +gst_tracing_register_hook (GstTracer * tracer, const gchar * detail, + GCallback func) +{ +} + #endif /* GST_DISABLE_GST_TRACER_HOOKS */