tracer: add the hook-id to the invoke signature
authorStefan Sauer <ensonic@users.sf.net>
Sun, 27 Oct 2013 11:45:54 +0000 (12:45 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Mon, 5 Oct 2015 18:59:39 +0000 (20:59 +0200)
Tracers that subscribe to multiple hooks can know what hook was used.

docs/design/draft-tracing.txt
gst/gsttracer.c
gst/gsttracer.h
plugins/tracers/gstlog.c

index 605ef34..ac4ef20 100644 (file)
@@ -95,18 +95,18 @@ Plugin api
 
 TracerPlugins are plugin features. They have a simple api:
 
-GstTracerHookMask init(gchar *params);
+'instance creation'
 Plugins can attach handlers to one or more hooks. They use a HookMask to tell
 which events they are interested in. The params are the extra detail from the
 environment var.
 
-void invoke(GstStructure *s);
+void invoke(GstTracerHookId id, GstStructure *s);
 Hooks marshall the parameters given to a trace hook into a GstStructure and also
 add some extra into such as a timestamp. The hooks will receive this structure.
 Hooks will be called from misc threads. The trace plugins should only consume 
 (=read) the provided data. Most trace plugins will log data to a trace channel.
 
-void done(void);
+'instance destruction'
 Plugins can output results and release data. This would ideally be done at the
 end of the applications, but gst_deinit() is not mandatory. gst_tracelib was
 using a gcc_destructor
index 45bedcc..2d0f703 100644 (file)
@@ -123,13 +123,13 @@ gst_tracer_get_property (GObject * object, guint prop_id,
 }
 
 static void
-gst_tracer_invoke (GstTracer * self, GstStructure * s)
+gst_tracer_invoke (GstTracer * self, GstTracerHookId id, GstStructure * s)
 {
   GstTracerClass *klass = GST_TRACER_GET_CLASS (self);
 
   g_return_if_fail (klass->invoke);
 
-  klass->invoke (s);
+  klass->invoke (id, s);
 }
 
 /* tracing modules */
@@ -287,7 +287,7 @@ dispatch (GstTracerHookId id, GstStructure * s)
 {
   GList *node;
   for (node = tracers[id]; node; node = g_list_next (node)) {
-    gst_tracer_invoke (node->data, s);
+    gst_tracer_invoke (node->data, id, s);
   }
 }
 
index f99e326..026edb4 100644 (file)
@@ -81,7 +81,7 @@ struct _GstTracer {
   gpointer _gst_reserved[GST_PADDING];
 };
 
-typedef void                 (*GstTracerInvokeFunction) (GstStructure *s);
+typedef void                 (*GstTracerInvokeFunction) (GstTracerHookId id, GstStructure *s);
 
 struct _GstTracerClass {
   GstObjectClass parent_class;
index a4c7c0c..f8cf95c 100644 (file)
@@ -34,7 +34,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_log_debug);
 G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
     _do_init);
 
-static void gst_log_tracer_invoke (GstStructure * s);
+static void gst_log_tracer_invoke (GstTracerHookId id, GstStructure * s);
 
 static void
 gst_log_tracer_class_init (GstLogTracerClass * klass)
@@ -51,10 +51,10 @@ gst_log_tracer_init (GstLogTracer * self)
 }
 
 static void
-gst_log_tracer_invoke (GstStructure * s)
+gst_log_tracer_invoke (GstTracerHookId id, GstStructure * s)
 {
   gchar *str = gst_structure_to_string (s);
-  /* TODO(ensonic): log to different categories depending on GstHookId */
+  /* TODO(ensonic): log to different categories depending on 'id' */
   GST_TRACE ("%s", str);
   g_free (str);
 }