tracing: add hooks when objects or miniobjects are created and destroyed

https://bugzilla.gnome.org/show_bug.cgi?id=765052
This commit is contained in:
Guillaume Desmottes 2016-05-09 16:31:36 +02:00 committed by Tim-Philipp Müller
parent 194964b4e0
commit 21070c8114
4 changed files with 87 additions and 1 deletions

View file

@ -129,6 +129,7 @@ gst_mini_object_init (GstMiniObject * mini_object, guint flags, GType type,
mini_object->n_qdata = 0; mini_object->n_qdata = 0;
mini_object->qdata = NULL; mini_object->qdata = NULL;
GST_TRACER_MINI_OBJECT_CREATED (mini_object);
#ifndef GST_DISABLE_TRACE #ifndef GST_DISABLE_TRACE
_gst_alloc_trace_new (_gst_mini_object_trace, mini_object); _gst_alloc_trace_new (_gst_mini_object_trace, mini_object);
#endif #endif
@ -460,6 +461,7 @@ gst_mini_object_unref (GstMiniObject * mini_object)
call_finalize_notify (mini_object); call_finalize_notify (mini_object);
g_free (mini_object->qdata); g_free (mini_object->qdata);
} }
GST_TRACER_MINI_OBJECT_DESTROYED (mini_object);
#ifndef GST_DISABLE_TRACE #ifndef GST_DISABLE_TRACE
_gst_alloc_trace_free (_gst_mini_object_trace, mini_object); _gst_alloc_trace_free (_gst_mini_object_trace, mini_object);
#endif #endif

View file

@ -153,6 +153,14 @@ static GParamSpec *properties[PROP_LAST];
G_DEFINE_ABSTRACT_TYPE (GstObject, gst_object, G_TYPE_INITIALLY_UNOWNED); 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 static void
gst_object_class_init (GstObjectClass * klass) gst_object_class_init (GstObjectClass * klass)
{ {
@ -208,6 +216,7 @@ gst_object_class_init (GstObjectClass * klass)
gobject_class->dispatch_properties_changed gobject_class->dispatch_properties_changed
= GST_DEBUG_FUNCPTR (gst_object_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->dispose = gst_object_dispose;
gobject_class->finalize = gst_object_finalize; gobject_class->finalize = gst_object_finalize;
} }
@ -415,6 +424,7 @@ gst_object_finalize (GObject * object)
g_free (gstobject->name); g_free (gstobject->name);
g_mutex_clear (&gstobject->lock); g_mutex_clear (&gstobject->lock);
GST_TRACER_OBJECT_DESTROYED (gstobject);
#ifndef GST_DISABLE_TRACE #ifndef GST_DISABLE_TRACE
_gst_alloc_trace_free (_gst_object_trace, object); _gst_alloc_trace_free (_gst_object_trace, object);
#endif #endif

View file

@ -55,7 +55,9 @@ static const gchar *_quark_strings[] = {
"element-new", "element-add-pad", "element-remove-pad", "element-new", "element-add-pad", "element-remove-pad",
"bin-add-pre", "bin-add-post", "bin-remove-pre", "bin-remove-post", "bin-add-pre", "bin-add-post", "bin-remove-pre", "bin-remove-post",
"pad-link-pre", "pad-link-post", "pad-unlink-pre", "pad-unlink-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]; GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX];

View file

@ -27,6 +27,7 @@
#include <glib-object.h> #include <glib-object.h>
#include <gst/gstconfig.h> #include <gst/gstconfig.h>
#include <gst/gstbin.h> #include <gst/gstbin.h>
#include <gst/gstutils.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -70,6 +71,10 @@ typedef enum /*< skip >*/
GST_TRACER_QUARK_HOOK_PAD_UNLINK_POST, GST_TRACER_QUARK_HOOK_PAD_UNLINK_POST,
GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_PRE, GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_PRE,
GST_TRACER_QUARK_HOOK_ELEMENT_CHANGE_STATE_POST, 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 GST_TRACER_QUARK_MAX
} GstTracerQuarkId; } GstTracerQuarkId;
@ -555,6 +560,69 @@ typedef void (*GstTracerHookPadUnlinkPost) (GObject *self, GstClockTime ts,
GstTracerHookPadUnlinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \ GstTracerHookPadUnlinkPost, (GST_TRACER_ARGS, srcpad, sinkpad, result)); \
}G_STMT_END }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 */ #else /* !GST_DISABLE_GST_TRACER_HOOKS */
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer) #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_LINK_POST(srcpad, sinkpad, res)
#define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad) #define GST_TRACER_PAD_UNLINK_PRE(srcpad, sinkpad)
#define GST_TRACER_PAD_UNLINK_POST(srcpad, sinkpad, res) #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 */ #endif /* GST_DISABLE_GST_TRACER_HOOKS */