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 @@ -153,6 +153,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) { @@ -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 #include #include +#include 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 */