From 68b1473846f34830c7bdb025afe397da9ea6de8f Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Sun, 27 Oct 2013 12:45:54 +0100 Subject: [PATCH] tracer: add the hook-id to the invoke signature Tracers that subscribe to multiple hooks can know what hook was used. --- docs/design/draft-tracing.txt | 6 +++--- gst/gsttracer.c | 6 +++--- gst/gsttracer.h | 2 +- plugins/tracers/gstlog.c | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/design/draft-tracing.txt b/docs/design/draft-tracing.txt index 605ef34..ac4ef20 100644 --- a/docs/design/draft-tracing.txt +++ b/docs/design/draft-tracing.txt @@ -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 diff --git a/gst/gsttracer.c b/gst/gsttracer.c index 45bedcc..2d0f703 100644 --- a/gst/gsttracer.c +++ b/gst/gsttracer.c @@ -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); } } diff --git a/gst/gsttracer.h b/gst/gsttracer.h index f99e326..026edb4 100644 --- a/gst/gsttracer.h +++ b/gst/gsttracer.h @@ -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; diff --git a/plugins/tracers/gstlog.c b/plugins/tracers/gstlog.c index a4c7c0c..f8cf95c 100644 --- a/plugins/tracers/gstlog.c +++ b/plugins/tracers/gstlog.c @@ -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); } -- 2.7.4