diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2016-05-09 16:31:36 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2016-06-02 23:10:44 +0100 |
commit | 21070c811469ad392d7a0f3af0b0de69bacdc153 (patch) | |
tree | d4ad0c3aed9b63f789eb9df99024a6326e9406eb | |
parent | 194964b4e03def69fc4c6c04bfa8e4e7daa2522e (diff) |
tracing: add hooks when objects or miniobjects are created and destroyed
https://bugzilla.gnome.org/show_bug.cgi?id=765052
-rw-r--r-- | gst/gstminiobject.c | 2 | ||||
-rw-r--r-- | gst/gstobject.c | 10 | ||||
-rw-r--r-- | gst/gsttracerutils.c | 4 | ||||
-rw-r--r-- | gst/gsttracerutils.h | 72 |
4 files changed, 87 insertions, 1 deletions
diff --git a/gst/gstminiobject.c b/gst/gstminiobject.c index 4812f31722..c45f082989 100644 --- a/gst/gstminiobject.c +++ b/gst/gstminiobject.c @@ -129,6 +129,7 @@ gst_mini_object_init (GstMiniObject * mini_object, guint flags, GType type, mini_object->n_qdata = 0; mini_object->qdata = NULL; + GST_TRACER_MINI_OBJECT_CREATED (mini_object); #ifndef GST_DISABLE_TRACE _gst_alloc_trace_new (_gst_mini_object_trace, mini_object); #endif @@ -460,6 +461,7 @@ gst_mini_object_unref (GstMiniObject * mini_object) call_finalize_notify (mini_object); g_free (mini_object->qdata); } + GST_TRACER_MINI_OBJECT_DESTROYED (mini_object); #ifndef GST_DISABLE_TRACE _gst_alloc_trace_free (_gst_mini_object_trace, mini_object); #endif diff --git a/gst/gstobject.c b/gst/gstobject.c index 372f3cfe7e..6090f31478 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -154,6 +154,14 @@ static GParamSpec *properties[PROP_LAST]; G_DEFINE_ABSTRACT_TYPE (GstObject, gst_object, G_TYPE_INITIALLY_UNOWNED); static void +gst_object_constructed (GObject * object) +{ + GST_TRACER_OBJECT_CREATED (GST_OBJECT_CAST (object)); + + ((GObjectClass *) gst_object_parent_class)->constructed (object); +} + +static void gst_object_class_init (GstObjectClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -208,6 +216,7 @@ gst_object_class_init (GstObjectClass * klass) gobject_class->dispatch_properties_changed = GST_DEBUG_FUNCPTR (gst_object_dispatch_properties_changed); + gobject_class->constructed = gst_object_constructed; gobject_class->dispose = gst_object_dispose; gobject_class->finalize = gst_object_finalize; } @@ -415,6 +424,7 @@ gst_object_finalize (GObject * object) g_free (gstobject->name); g_mutex_clear (&gstobject->lock); + GST_TRACER_OBJECT_DESTROYED (gstobject); #ifndef GST_DISABLE_TRACE _gst_alloc_trace_free (_gst_object_trace, object); #endif diff --git a/gst/gsttracerutils.c b/gst/gsttracerutils.c index 3088b063bf..85689e5d06 100644 --- a/gst/gsttracerutils.c +++ b/gst/gsttracerutils.c @@ -55,7 +55,9 @@ 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", }; GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX]; diff --git a/gst/gsttracerutils.h b/gst/gsttracerutils.h index 64cc14c196..e61d66d414 100644 --- a/gst/gsttracerutils.h +++ b/gst/gsttracerutils.h @@ -27,6 +27,7 @@ #include <glib-object.h> #include <gst/gstconfig.h> #include <gst/gstbin.h> +#include <gst/gstutils.h> G_BEGIN_DECLS @@ -70,6 +71,10 @@ typedef enum /*< skip >*/ GST_TRACER_QUARK_HOOK_PAD_UNLINK_POST, GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_PRE, GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_POST, + GST_TRACER_QUARK_HOOK_MINI_OBJECT_CREATED, + GST_TRACER_QUARK_HOOK_MINI_OBJECT_DESTROYED, + GST_TRACER_QUARK_HOOK_OBJECT_CREATED, + GST_TRACER_QUARK_HOOK_OBJECT_DESTROYED, GST_TRACER_QUARK_MAX } GstTracerQuarkId; @@ -555,6 +560,69 @@ typedef void (*GstTracerHookPadUnlinkPost) (GObject *self, GstClockTime ts, GstTracerHookPadUnlinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \ }G_STMT_END +/** + * GstTracerHookMiniObjectCreated: + * @self: the tracer instance + * @ts: the current timestamp + * @object: the mini object being created + * + * Hook called when a #GstMiniObject is created named "mini-object-created". + */ +typedef void (*GstTracerHookMiniObjectCreated) (GObject *self, GstClockTime ts, + GstMiniObject *object); +#define GST_TRACER_MINI_OBJECT_CREATED(object) G_STMT_START{ \ + GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_CREATED), \ + GstTracerHookMiniObjectCreated, (GST_TRACER_ARGS, object)); \ +}G_STMT_END + +/** + * GstTracerHookMiniObjectDestroyed: + * @self: the tracer instance + * @ts: the current timestamp + * @object: the mini object being destroyed + * + * Hook called when a #GstMiniObject is being destroyed named + * "mini-object-destroyed". + */ +typedef void (*GstTracerHookMiniObjectDestroyed) (GObject *self, GstClockTime ts, + GstMiniObject *object); +#define GST_TRACER_MINI_OBJECT_DESTROYED(object) G_STMT_START{ \ + GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_MINI_OBJECT_DESTROYED), \ + GstTracerHookMiniObjectDestroyed, (GST_TRACER_ARGS, object)); \ +}G_STMT_END + +/** + * GstTracerHookObjectCreated: + * @self: the tracer instance + * @ts: the current timestamp + * @object: the object being created + * + * Hook called when a #GstObject is created named "object-created". + */ +typedef void (*GstTracerHookObjectCreated) (GObject *self, GstClockTime ts, + GstObject *object); +#define GST_TRACER_OBJECT_CREATED(object) G_STMT_START{ \ + GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_OBJECT_CREATED), \ + GstTracerHookObjectCreated, (GST_TRACER_ARGS, object)); \ +}G_STMT_END + +/** + * GstTracerHookObjectDestroyed: + * @self: the tracer instance + * @ts: the current timestamp + * @object: the object being destroyed + * + * Hook called when a #GstObject is being destroyed named + * "object-destroyed". + */ +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 + + #else /* !GST_DISABLE_GST_TRACER_HOOKS */ #define GST_TRACER_PAD_PUSH_PRE(pad, buffer) @@ -584,6 +652,10 @@ typedef void (*GstTracerHookPadUnlinkPost) (GObject *self, GstClockTime ts, #define GST_TRACER_PAD_LINK_POST(srcpad, sinkpad, res) #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad) #define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, res) +#define GST_TRACER_MINI_OBJECT_CREATED(object) +#define GST_TRACER_MINI_OBJECT_DESTROYED(object) +#define GST_TRACER_OBJECT_CREATED(object) +#define GST_TRACER_OBJECT_DESTROYED(object) #endif /* GST_DISABLE_GST_TRACER_HOOKS */ |