tracers: Add tracepoint when a plugin feature it loaded
authorOlivier Crête <olivier.crete@collabora.com>
Fri, 23 Apr 2021 19:34:26 +0000 (15:34 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Wed, 18 Aug 2021 21:01:27 +0000 (17:01 -0400)
This makes it possible to trace which ones are loaded in a specific
program to make nice statistics.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/782>

gst/gstpluginfeature.c
gst/gsttracerutils.c
gst/gsttracerutils.h

index e7c741de8bccb160248402584e1d209ae456ae5c..ac61cc0e11289fee6d0db28daaee30add9d1599e 100644 (file)
@@ -124,6 +124,8 @@ gst_plugin_feature_load (GstPluginFeature * feature)
   else if (!real_feature->loaded)
     goto not_found;
 
+  GST_TRACER_PLUGIN_FEATURE_LOADED (real_feature);
+
   return real_feature;
 
   /* ERRORS */
index ea9c9e320a2d7ecc34f676e70851d377ab487a86..cc92e6448dbe635a09b4a17a26d93db454a4bd66 100644 (file)
@@ -54,7 +54,7 @@ static const gchar *_quark_strings[] = {
   "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",
+  "object-reffed", "object-unreffed", "plugin-feature-loaded"
 };
 
 GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX];
index a2a5ed6d2a2141c808014ea85b5b615fd39db49b..48b0864015b05ddb1252ba9ce45d1f349895d5ee 100644 (file)
@@ -79,6 +79,7 @@ typedef enum /*< skip >*/
   GST_TRACER_QUARK_HOOK_MINI_OBJECT_UNREFFED,
   GST_TRACER_QUARK_HOOK_OBJECT_REFFED,
   GST_TRACER_QUARK_HOOK_OBJECT_UNREFFED,
+  GST_TRACER_QUARK_HOOK_PLUGIN_FEATURE_LOADED,
   GST_TRACER_QUARK_MAX
 } GstTracerQuarkId;
 
@@ -689,11 +690,38 @@ typedef void (*GstTracerHookObjectCreated) (GObject *self, GstClockTime ts,
  */
 typedef void (*GstTracerHookObjectDestroyed) (GObject *self, GstClockTime ts,
     GstObject *object);
+
 #define GST_TRACER_OBJECT_DESTROYED(object) G_STMT_START{ \
   GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_DESTROYED), \
     GstTracerHookObjectDestroyed, (GST_TRACER_ARGS, object)); \
 }G_STMT_END
 
+/**
+ * GstTracerHookPluginFeatureLoaded:
+ * @self: the tracer instance
+ * @ts: the current timestamp
+ * @feature: the plugin feature that was loaded
+ *
+ * Hook called when a GstPluginFeature is loaded named
+ * "plugin-feature-loaded".
+ *
+ * Since: 1.20
+ */
+typedef void (*GstTracerHookPluginFeatureLoaded) (GObject *self, GstClockTime ts,
+    GstPluginFeature *feature);
+/**
+ * GST_TRACER_PLUGIN_FEATURE_LOADED:
+ * @feature: The feature that this tracer is called for
+ *
+ * Add a tracepoint when a plugin feature is loaded.
+ *
+ * Since: 1.20
+ */
+#define GST_TRACER_PLUGIN_FEATURE_LOADED(feature) G_STMT_START{ \
+  GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PLUGIN_FEATURE_LOADED), \
+    GstTracerHookPluginFeatureLoaded, (GST_TRACER_ARGS, feature)); \
+}G_STMT_END
+
 
 #else /* !GST_DISABLE_GST_TRACER_HOOKS */
 
@@ -743,6 +771,7 @@ _priv_gst_tracing_deinit (void)
 #define GST_TRACER_OBJECT_DESTROYED(object)
 #define GST_TRACER_OBJECT_REFFED(object, new_refcount)
 #define GST_TRACER_OBJECT_UNREFFED(object, new_refcount)
+#define GST_TRACER_PLUGIN_FEATURE_LOADED(feature)
 
 #endif /* GST_DISABLE_GST_TRACER_HOOKS */