mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
tracers: eliminate var_args
Register tracer hooks as GCallback. Use macros for hook dispatch and cast the hook functions back to the appropriate type.
This commit is contained in:
parent
f09dd66cf6
commit
5e2770566f
7 changed files with 185 additions and 216 deletions
|
@ -53,8 +53,6 @@ struct _GstTracer {
|
|||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
typedef void (*GstTracerHookFunction) (GstTracer * self, va_list var_args);
|
||||
|
||||
struct _GstTracerClass {
|
||||
GstObjectClass parent_class;
|
||||
|
||||
|
@ -65,9 +63,9 @@ struct _GstTracerClass {
|
|||
GType gst_tracer_get_type (void);
|
||||
|
||||
void gst_tracer_register_hook (GstTracer *tracer, const gchar *detail,
|
||||
GstTracerHookFunction func);
|
||||
GCallback func);
|
||||
void gst_tracer_register_hook_id (GstTracer *tracer, GQuark detail,
|
||||
GstTracerHookFunction func);
|
||||
GCallback func);
|
||||
|
||||
void gst_tracer_log_trace (GstStructure * s);
|
||||
|
||||
|
|
|
@ -57,12 +57,6 @@ GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX];
|
|||
gboolean _priv_tracer_enabled = FALSE;
|
||||
GHashTable *_priv_tracers = NULL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GstTracer *tracer;
|
||||
GstTracerHookFunction func;
|
||||
} GstTracerHook;
|
||||
|
||||
/* Initialize the tracing system */
|
||||
void
|
||||
_priv_gst_tracer_init (void)
|
||||
|
@ -153,8 +147,7 @@ _priv_gst_tracer_deinit (void)
|
|||
}
|
||||
|
||||
void
|
||||
gst_tracer_register_hook_id (GstTracer * tracer, GQuark detail,
|
||||
GstTracerHookFunction func)
|
||||
gst_tracer_register_hook_id (GstTracer * tracer, GQuark detail, GCallback func)
|
||||
{
|
||||
gpointer key = GINT_TO_POINTER (detail);
|
||||
GList *list = g_hash_table_lookup (_priv_tracers, key);
|
||||
|
@ -171,36 +164,9 @@ gst_tracer_register_hook_id (GstTracer * tracer, GQuark detail,
|
|||
|
||||
void
|
||||
gst_tracer_register_hook (GstTracer * tracer, const gchar * detail,
|
||||
GstTracerHookFunction func)
|
||||
GCallback func)
|
||||
{
|
||||
gst_tracer_register_hook_id (tracer, g_quark_try_string (detail), func);
|
||||
}
|
||||
|
||||
void
|
||||
gst_tracer_dispatch (GQuark detail, ...)
|
||||
{
|
||||
va_list var_args;
|
||||
gpointer key = GINT_TO_POINTER (detail);
|
||||
GList *list, *node;
|
||||
GstTracerHook *hook;
|
||||
|
||||
list = g_hash_table_lookup (_priv_tracers, key);
|
||||
GST_DEBUG ("calling %d tracers for '%s'", g_list_length (list),
|
||||
g_quark_to_string (detail));
|
||||
for (node = list; node; node = g_list_next (node)) {
|
||||
hook = (GstTracerHook *) node->data;
|
||||
va_start (var_args, detail);
|
||||
hook->func (hook->tracer, var_args);
|
||||
va_end (var_args);
|
||||
}
|
||||
list = g_hash_table_lookup (_priv_tracers, NULL);
|
||||
GST_DEBUG ("calling %d tracers for '*'", g_list_length (list));
|
||||
for (node = list; node; node = g_list_next (node)) {
|
||||
hook = (GstTracerHook *) node->data;
|
||||
va_start (var_args, detail);
|
||||
hook->func (hook->tracer, var_args);
|
||||
va_end (var_args);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GST_DISABLE_GST_DEBUG */
|
||||
|
|
|
@ -41,10 +41,6 @@ void _priv_gst_tracer_deinit (void);
|
|||
|
||||
gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
|
||||
|
||||
/* tracing helpers */
|
||||
|
||||
void gst_tracer_dispatch (GQuark detail, ...);
|
||||
|
||||
/* tracer quarks */
|
||||
|
||||
/* These enums need to match the number and order
|
||||
|
@ -72,112 +68,123 @@ extern GQuark _priv_gst_tracer_quark_table[GST_TRACER_QUARK_MAX];
|
|||
|
||||
/* tracing module helpers */
|
||||
|
||||
typedef struct {
|
||||
GObject *tracer;
|
||||
GCallback func;
|
||||
} GstTracerHook;
|
||||
|
||||
extern gboolean _priv_tracer_enabled;
|
||||
/* key are hook-id quarks, values are GstTracerHook */
|
||||
extern GHashTable *_priv_tracers;
|
||||
|
||||
#define GST_TRACER_IS_ENABLED(id) \
|
||||
(_priv_tracer_enabled && \
|
||||
(g_hash_table_contains (_priv_tracers, GINT_TO_POINTER(id))))
|
||||
#define GST_TRACER_IS_ENABLED (_priv_tracer_enabled)
|
||||
|
||||
#define GST_TRACER_TS \
|
||||
GST_CLOCK_DIFF (_priv_gst_info_start_time, gst_util_get_timestamp ())
|
||||
|
||||
/* tracing hooks */
|
||||
|
||||
#define GST_TRACER_ARGS h->tracer, ts
|
||||
#define GST_TRACER_DISPATCH(key,type,args) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED) { \
|
||||
GstClockTime ts = GST_TRACER_TS; \
|
||||
GList *__l, *__n; \
|
||||
GstTracerHook *h; \
|
||||
__l = g_hash_table_lookup (_priv_tracers, GINT_TO_POINTER (key)); \
|
||||
for (__n = __l; __n; __n = g_list_next (__n)) { \
|
||||
h = (GstTracerHook *) __n->data; \
|
||||
((type)(h->func)) args; \
|
||||
} \
|
||||
__l = g_hash_table_lookup (_priv_tracers, NULL); \
|
||||
for (__n = __l; __n; __n = g_list_next (__n)) { \
|
||||
h = (GstTracerHook *) __n->data; \
|
||||
((type)(h->func)) args; \
|
||||
} \
|
||||
} \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPushPre) (GObject *, GstClockTime, GstPad *,
|
||||
GstBuffer *);
|
||||
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PUSH_PRE))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PUSH_PRE), \
|
||||
GST_TRACER_TS, \
|
||||
pad, buffer); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_PRE), \
|
||||
GstTracerHookPadPushPre, (GST_TRACER_ARGS, pad, buffer)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPushPost) (GObject *, GstClockTime, GstPad *,
|
||||
GstFlowReturn);
|
||||
#define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PUSH_POST))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PUSH_POST), \
|
||||
GST_TRACER_TS, \
|
||||
pad, res); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_POST), \
|
||||
GstTracerHookPadPushPost, (GST_TRACER_ARGS, pad, res)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPushListPre) (GObject *, GstClockTime, GstPad *,
|
||||
GstBufferList *);
|
||||
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_PRE))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_PRE), \
|
||||
GST_TRACER_TS, \
|
||||
pad, list); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_PRE), \
|
||||
GstTracerHookPadPushListPre, (GST_TRACER_ARGS, pad, list)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPushListPost) (GObject *, GstClockTime, GstPad *,
|
||||
GstFlowReturn);
|
||||
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_POST))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_POST), \
|
||||
GST_TRACER_TS, \
|
||||
pad, res); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_LIST_POST), \
|
||||
GstTracerHookPadPushListPost, (GST_TRACER_ARGS, pad, res)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPullRangePre) (GObject *, GstClockTime, GstPad *,
|
||||
guint64, guint);
|
||||
#define GST_TRACER_PAD_PULL_RANGE_PRE(pad, offset, size) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_PRE))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_PRE), \
|
||||
GST_TRACER_TS, \
|
||||
pad, offset, size); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_PRE), \
|
||||
GstTracerHookPadPullRangePre, (GST_TRACER_ARGS, pad, offset, size)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPullRangePost) (GObject *, GstClockTime,
|
||||
GstPad *, GstBuffer *, GstFlowReturn);
|
||||
#define GST_TRACER_PAD_PULL_RANGE_POST(pad, buffer, res) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_POST))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_POST), \
|
||||
GST_TRACER_TS, \
|
||||
pad, buffer, res); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PULL_RANGE_POST), \
|
||||
GstTracerHookPadPullRangePost, (GST_TRACER_ARGS, pad, buffer, res)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPushEventPre) (GObject *, GstClockTime, GstPad *,
|
||||
GstEvent *);
|
||||
#define GST_TRACER_PAD_PUSH_EVENT_PRE(pad, event) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_PRE))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_PRE), \
|
||||
GST_TRACER_TS, \
|
||||
pad, event); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_PRE), \
|
||||
GstTracerHookPadPushEventPre, (GST_TRACER_ARGS, pad, event)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookPadPushEventPost) (GObject *, GstClockTime,
|
||||
GstPad *, gboolean);
|
||||
#define GST_TRACER_PAD_PUSH_EVENT_POST(pad, res) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_POST))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_POST), \
|
||||
GST_TRACER_TS, \
|
||||
pad, res); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_PAD_PUSH_EVENT_POST), \
|
||||
GstTracerHookPadPushEventPost, (GST_TRACER_ARGS, pad, res)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookElementPostMessagePre) (GObject *, GstClockTime,
|
||||
GstElement *, GstMessage *);
|
||||
#define GST_TRACER_ELEMENT_POST_MESSAGE_PRE(element, message) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_PRE))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_PRE), \
|
||||
GST_TRACER_TS, \
|
||||
element, message); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_PRE), \
|
||||
GstTracerHookElementPostMessagePre, (GST_TRACER_ARGS, element, message)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookElementPostMessagePost) (GObject *, GstClockTime,
|
||||
GstElement *, gboolean);
|
||||
#define GST_TRACER_ELEMENT_POST_MESSAGE_POST(element, res) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_POST))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_POST), \
|
||||
GST_TRACER_TS, \
|
||||
element, res); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_POST_MESSAGE_POST), \
|
||||
GstTracerHookElementPostMessagePost, (GST_TRACER_ARGS, element, res)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookElementQueryPre) (GObject *, GstClockTime,
|
||||
GstElement *, GstQuery *);
|
||||
#define GST_TRACER_ELEMENT_QUERY_PRE(element, query) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_PRE))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_PRE), \
|
||||
GST_TRACER_TS, \
|
||||
element, query); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_PRE), \
|
||||
GstTracerHookElementQueryPre, (GST_TRACER_ARGS, element, query)); \
|
||||
}G_STMT_END
|
||||
|
||||
typedef void (*GstTracerHookElementQueryPost) (GObject *, GstClockTime,
|
||||
GstElement *, gboolean);
|
||||
#define GST_TRACER_ELEMENT_QUERY_POST(element, res) G_STMT_START{ \
|
||||
if (GST_TRACER_IS_ENABLED(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_POST))) { \
|
||||
gst_tracer_dispatch (GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_POST), \
|
||||
GST_TRACER_TS, \
|
||||
element, res); \
|
||||
} \
|
||||
GST_TRACER_DISPATCH(GST_TRACER_QUARK(HOOK_ELEMENT_QUERY_POST), \
|
||||
GstTracerHookElementQueryPost, (GST_TRACER_ARGS, element, res)); \
|
||||
}G_STMT_END
|
||||
|
||||
#else /* !GST_DISABLE_GST_DEBUG */
|
||||
|
|
|
@ -127,20 +127,16 @@ send_latency_probe (GstElement * parent, GstPad * pad, guint64 ts)
|
|||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_pre (GstTracer * self, va_list var_args)
|
||||
do_push_buffer_pre (GstTracer * self, guint64 ts, GstPad * pad)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstElement *parent = get_real_pad_parent (pad);
|
||||
|
||||
send_latency_probe (parent, pad, ts);
|
||||
}
|
||||
|
||||
static void
|
||||
do_pull_range_pre (GstTracer * self, va_list var_args)
|
||||
do_pull_range_pre (GstTracer * self, guint64 ts, GstPad * pad)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstPad *peer_pad = GST_PAD_PEER (pad);
|
||||
GstElement *parent = get_real_pad_parent (peer_pad);
|
||||
|
||||
|
@ -160,10 +156,8 @@ calculate_latency (GstElement * parent, GstPad * pad, guint64 ts)
|
|||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_post (GstTracer * self, va_list var_args)
|
||||
do_push_buffer_post (GstTracer * self, guint64 ts, GstPad * pad)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstPad *peer_pad = GST_PAD_PEER (pad);
|
||||
GstElement *parent = get_real_pad_parent (peer_pad);
|
||||
|
||||
|
@ -171,21 +165,16 @@ do_push_buffer_post (GstTracer * self, va_list var_args)
|
|||
}
|
||||
|
||||
static void
|
||||
do_pull_range_post (GstTracer * self, va_list var_args)
|
||||
do_pull_range_post (GstTracer * self, guint64 ts, GstPad * pad)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstElement *parent = get_real_pad_parent (pad);
|
||||
|
||||
calculate_latency (parent, pad, ts);
|
||||
}
|
||||
|
||||
static void
|
||||
do_push_event_pre (GstTracer * self, va_list var_args)
|
||||
do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * ev)
|
||||
{
|
||||
G_GNUC_UNUSED guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstEvent *ev = va_arg (var_args, GstEvent *);
|
||||
GstPad *peer_pad = GST_PAD_PEER (pad);
|
||||
GstElement *parent = get_real_pad_parent (peer_pad);
|
||||
|
||||
|
@ -238,11 +227,18 @@ static void
|
|||
gst_latency_tracer_init (GstLatencyTracer * self)
|
||||
{
|
||||
GstTracer *tracer = GST_TRACER (self);
|
||||
gst_tracer_register_hook (tracer, "pad-push-pre", do_push_buffer_pre);
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-pre", do_push_buffer_pre);
|
||||
gst_tracer_register_hook (tracer, "pad-push-post", do_push_buffer_post);
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-post", do_push_buffer_post);
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-pre", do_pull_range_pre);
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-post", do_pull_range_post);
|
||||
gst_tracer_register_hook (tracer, "pad-push-event-pre", do_push_event_pre);
|
||||
gst_tracer_register_hook (tracer, "pad-push-pre",
|
||||
G_CALLBACK (do_push_buffer_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-pre",
|
||||
G_CALLBACK (do_push_buffer_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-push-post",
|
||||
G_CALLBACK (do_push_buffer_post));
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-post",
|
||||
G_CALLBACK (do_push_buffer_post));
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-pre",
|
||||
G_CALLBACK (do_pull_range_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-post",
|
||||
G_CALLBACK (do_pull_range_post));
|
||||
gst_tracer_register_hook (tracer, "pad-push-event-pre",
|
||||
G_CALLBACK (do_push_event_pre));
|
||||
}
|
||||
|
|
|
@ -53,100 +53,113 @@ G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
|
|||
_do_init);
|
||||
|
||||
static void
|
||||
do_log (GstDebugCategory * cat, const char *format, va_list var_args)
|
||||
do_log (GstDebugCategory * cat, const char *fmt, ...)
|
||||
{
|
||||
gst_debug_log_valist (cat, GST_LEVEL_TRACE, "", "", 0, NULL,
|
||||
format, var_args);
|
||||
va_list var_args;
|
||||
|
||||
va_start (var_args, fmt);
|
||||
gst_debug_log_valist (cat, GST_LEVEL_TRACE, "", "", 0, NULL, fmt, var_args);
|
||||
va_end (var_args);
|
||||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_pre (GstTracer * self, va_list var_args)
|
||||
do_push_buffer_pre (GstTracer * self, guint64 ts, GstPad * pad,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
do_log (GST_CAT_BUFFER,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT,
|
||||
var_args);
|
||||
ts, pad, buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_post (GstTracer * self, va_list var_args)
|
||||
do_push_buffer_post (GstTracer * self, guint64 ts, GstPad * pad,
|
||||
GstFlowReturn res)
|
||||
{
|
||||
do_log (GST_CAT_BUFFER,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", var_args);
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", ts, pad, res);
|
||||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_list_pre (GstTracer * self, va_list var_args)
|
||||
do_push_buffer_list_pre (GstTracer * self, guint64 ts, GstPad * pad,
|
||||
GstBufferList * list)
|
||||
{
|
||||
do_log (GST_CAT_BUFFER_LIST,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", list=%p", var_args);
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", list=%p", ts, pad, list);
|
||||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_list_post (GstTracer * self, va_list var_args)
|
||||
do_push_buffer_list_post (GstTracer * self, guint64 ts, GstPad * pad,
|
||||
GstFlowReturn res)
|
||||
{
|
||||
do_log (GST_CAT_BUFFER_LIST,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", var_args);
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", ts, pad, res);
|
||||
}
|
||||
|
||||
static void
|
||||
do_pull_range_pre (GstTracer * self, va_list var_args)
|
||||
do_pull_range_pre (GstTracer * self, guint64 ts, GstPad * pad, guint64 offset,
|
||||
guint size)
|
||||
{
|
||||
do_log (GST_CAT_BUFFER,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", offset=%" G_GUINT64_FORMAT
|
||||
", size=%u", var_args);
|
||||
", size=%u", ts, pad, offset, size);
|
||||
}
|
||||
|
||||
static void
|
||||
do_pull_range_post (GstTracer * self, va_list var_args)
|
||||
do_pull_range_post (GstTracer * self, guint64 ts, GstPad * pad,
|
||||
GstBuffer * buffer, GstFlowReturn res)
|
||||
{
|
||||
do_log (GST_CAT_BUFFER,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT
|
||||
", res=%d", var_args);
|
||||
", res=%d", ts, pad, buffer, res);
|
||||
}
|
||||
|
||||
static void
|
||||
do_push_event_pre (GstTracer * self, va_list var_args)
|
||||
do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * event)
|
||||
{
|
||||
do_log (GST_CAT_EVENT,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", event=%" GST_PTR_FORMAT,
|
||||
var_args);
|
||||
ts, pad, event);
|
||||
}
|
||||
|
||||
static void
|
||||
do_push_event_post (GstTracer * self, va_list var_args)
|
||||
do_push_event_post (GstTracer * self, guint64 ts, GstPad * pad, gboolean res)
|
||||
{
|
||||
do_log (GST_CAT_EVENT,
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", var_args);
|
||||
"%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", ts, pad, res);
|
||||
}
|
||||
|
||||
static void
|
||||
do_post_message_pre (GstTracer * self, va_list var_args)
|
||||
do_post_message_pre (GstTracer * self, guint64 ts, GstElement * elem,
|
||||
GstMessage * msg)
|
||||
{
|
||||
do_log (GST_CAT_EVENT,
|
||||
"%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", message=%"
|
||||
GST_PTR_FORMAT, var_args);
|
||||
GST_PTR_FORMAT, ts, elem, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
do_post_message_post (GstTracer * self, va_list var_args)
|
||||
do_post_message_post (GstTracer * self, guint64 ts, GstElement * elem,
|
||||
gboolean res)
|
||||
{
|
||||
do_log (GST_CAT_EVENT,
|
||||
"%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", var_args);
|
||||
"%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", ts, elem,
|
||||
res);
|
||||
}
|
||||
|
||||
static void
|
||||
do_query_pre (GstTracer * self, va_list var_args)
|
||||
do_query_pre (GstTracer * self, guint64 ts, GstElement * elem, GstQuery * query)
|
||||
{
|
||||
do_log (GST_CAT_QUERY,
|
||||
"%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", query=%"
|
||||
GST_PTR_FORMAT, var_args);
|
||||
GST_PTR_FORMAT, ts, elem, query);
|
||||
}
|
||||
|
||||
static void
|
||||
do_query_post (GstTracer * self, va_list var_args)
|
||||
do_query_post (GstTracer * self, guint64 ts, GstElement * elem, gboolean res)
|
||||
{
|
||||
do_log (GST_CAT_QUERY,
|
||||
"%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", var_args);
|
||||
"%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", ts, elem,
|
||||
res);
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,20 +175,28 @@ gst_log_tracer_init (GstLogTracer * self)
|
|||
{
|
||||
GstTracer *tracer = GST_TRACER (self);
|
||||
|
||||
gst_tracer_register_hook (tracer, "pad-push-pre", do_push_buffer_pre);
|
||||
gst_tracer_register_hook (tracer, "pad-push-post", do_push_buffer_post);
|
||||
gst_tracer_register_hook (tracer, "pad-push-pre",
|
||||
G_CALLBACK (do_push_buffer_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-push-post",
|
||||
G_CALLBACK (do_push_buffer_post));
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-pre",
|
||||
do_push_buffer_list_pre);
|
||||
G_CALLBACK (do_push_buffer_list_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-post",
|
||||
do_push_buffer_list_post);
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-pre", do_pull_range_pre);
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-post", do_pull_range_post);
|
||||
gst_tracer_register_hook (tracer, "pad-push-event-pre", do_push_event_pre);
|
||||
gst_tracer_register_hook (tracer, "pad-push-event-post", do_push_event_post);
|
||||
G_CALLBACK (do_push_buffer_list_post));
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-pre",
|
||||
G_CALLBACK (do_pull_range_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-post",
|
||||
G_CALLBACK (do_pull_range_post));
|
||||
gst_tracer_register_hook (tracer, "pad-push-event-pre",
|
||||
G_CALLBACK (do_push_event_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-push-event-post",
|
||||
G_CALLBACK (do_push_event_post));
|
||||
gst_tracer_register_hook (tracer, "element-post-message-pre",
|
||||
do_post_message_pre);
|
||||
G_CALLBACK (do_post_message_pre));
|
||||
gst_tracer_register_hook (tracer, "element-post-message-post",
|
||||
do_post_message_post);
|
||||
gst_tracer_register_hook (tracer, "element-query-pre", do_query_pre);
|
||||
gst_tracer_register_hook (tracer, "element-query-post", do_query_post);
|
||||
G_CALLBACK (do_post_message_post));
|
||||
gst_tracer_register_hook (tracer, "element-query-pre",
|
||||
G_CALLBACK (do_query_pre));
|
||||
gst_tracer_register_hook (tracer, "element-query-post",
|
||||
G_CALLBACK (do_query_post));
|
||||
}
|
||||
|
|
|
@ -146,10 +146,9 @@ free_thread_stats (gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
do_stats (GstTracer * obj, va_list var_args)
|
||||
do_stats (GstTracer * obj, guint64 ts)
|
||||
{
|
||||
GstRUsageTracer *self = GST_RUSAGE_TRACER_CAST (obj);
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstThreadStats *stats;
|
||||
gpointer thread_id = g_thread_self ();
|
||||
guint avg_cpuload, cur_cpuload;
|
||||
|
@ -348,7 +347,7 @@ gst_rusage_tracer_init (GstRUsageTracer * self)
|
|||
{
|
||||
GstTracer *tracer = GST_TRACER (self);
|
||||
|
||||
gst_tracer_register_hook_id (tracer, 0, do_stats);
|
||||
gst_tracer_register_hook_id (tracer, 0, G_CALLBACK (do_stats));
|
||||
|
||||
self->threads = g_hash_table_new_full (NULL, NULL, NULL, free_thread_stats);
|
||||
self->tvs_proc = make_trace_values (GST_SECOND);
|
||||
|
|
|
@ -336,11 +336,9 @@ do_element_stats (GstStatsTracer * self, GstPad * pad, GstClockTime elapsed1,
|
|||
/* hooks */
|
||||
|
||||
static void
|
||||
do_push_buffer_pre (GstStatsTracer * self, va_list var_args)
|
||||
do_push_buffer_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *this_pad = va_arg (var_args, GstPad *);
|
||||
GstBuffer *buffer = va_arg (var_args, GstBuffer *);
|
||||
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
||||
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
||||
GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
|
||||
|
@ -350,10 +348,8 @@ do_push_buffer_pre (GstStatsTracer * self, va_list var_args)
|
|||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_post (GstStatsTracer * self, va_list var_args)
|
||||
do_push_buffer_post (GstStatsTracer * self, guint64 ts, GstPad * pad)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstPadStats *stats = get_pad_stats (self, pad);
|
||||
|
||||
do_element_stats (self, pad, stats->last_ts, ts);
|
||||
|
@ -380,11 +376,9 @@ do_push_buffer_list_item (GstBuffer ** buffer, guint idx, gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_list_pre (GstStatsTracer * self, va_list var_args)
|
||||
do_push_buffer_list_pre (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
||||
GstBufferList * list)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *this_pad = va_arg (var_args, GstPad *);
|
||||
GstBufferList *list = va_arg (var_args, GstBufferList *);
|
||||
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
||||
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
||||
GstPadStats *that_pad_stats = get_pad_stats (self, that_pad);
|
||||
|
@ -396,30 +390,24 @@ do_push_buffer_list_pre (GstStatsTracer * self, va_list var_args)
|
|||
}
|
||||
|
||||
static void
|
||||
do_push_buffer_list_post (GstStatsTracer * self, va_list var_args)
|
||||
do_push_buffer_list_post (GstStatsTracer * self, guint64 ts, GstPad * pad)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstPadStats *stats = get_pad_stats (self, pad);
|
||||
|
||||
do_element_stats (self, pad, stats->last_ts, ts);
|
||||
}
|
||||
|
||||
static void
|
||||
do_pull_range_pre (GstStatsTracer * self, va_list var_args)
|
||||
do_pull_range_pre (GstStatsTracer * self, guint64 ts, GstPad * pad)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstPadStats *stats = get_pad_stats (self, pad);
|
||||
stats->last_ts = ts;
|
||||
}
|
||||
|
||||
static void
|
||||
do_pull_range_post (GstStatsTracer * self, va_list var_args)
|
||||
do_pull_range_post (GstStatsTracer * self, guint64 ts, GstPad * this_pad,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *this_pad = va_arg (var_args, GstPad *);
|
||||
GstBuffer *buffer = va_arg (var_args, GstBuffer *);
|
||||
GstPadStats *this_pad_stats = get_pad_stats (self, this_pad);
|
||||
guint64 last_ts = this_pad_stats->last_ts;
|
||||
GstPad *that_pad = GST_PAD_PEER (this_pad);
|
||||
|
@ -433,11 +421,9 @@ do_pull_range_post (GstStatsTracer * self, va_list var_args)
|
|||
}
|
||||
|
||||
static void
|
||||
do_push_event_pre (GstStatsTracer * self, va_list var_args)
|
||||
do_push_event_pre (GstStatsTracer * self, guint64 ts, GstPad * pad,
|
||||
GstEvent * ev)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstPad *pad = va_arg (var_args, GstPad *);
|
||||
GstEvent *ev = va_arg (var_args, GstEvent *);
|
||||
GstElement *elem = get_real_pad_parent (pad);
|
||||
GstElementStats *elem_stats = get_element_stats (self, elem);
|
||||
GstPadStats *pad_stats = get_pad_stats (self, pad);
|
||||
|
@ -451,11 +437,9 @@ do_push_event_pre (GstStatsTracer * self, va_list var_args)
|
|||
}
|
||||
|
||||
static void
|
||||
do_post_message_pre (GstStatsTracer * self, va_list var_args)
|
||||
do_post_message_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
|
||||
GstMessage * msg)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstElement *elem = va_arg (var_args, GstElement *);
|
||||
GstMessage *msg = va_arg (var_args, GstMessage *);
|
||||
GstElementStats *stats = get_element_stats (self, elem);
|
||||
|
||||
stats->last_ts = ts;
|
||||
|
@ -466,11 +450,9 @@ do_post_message_pre (GstStatsTracer * self, va_list var_args)
|
|||
}
|
||||
|
||||
static void
|
||||
do_query_pre (GstStatsTracer * self, va_list var_args)
|
||||
do_query_pre (GstStatsTracer * self, guint64 ts, GstElement * elem,
|
||||
GstQuery * qry)
|
||||
{
|
||||
guint64 ts = va_arg (var_args, guint64);
|
||||
GstElement *elem = va_arg (var_args, GstElement *);
|
||||
GstQuery *qry = va_arg (var_args, GstQuery *);
|
||||
GstElementStats *stats = get_element_stats (self, elem);
|
||||
|
||||
stats->last_ts = ts;
|
||||
|
@ -565,21 +547,21 @@ gst_stats_tracer_init (GstStatsTracer * self)
|
|||
GstTracer *tracer = GST_TRACER (self);
|
||||
|
||||
gst_tracer_register_hook (tracer, "pad-push-pre",
|
||||
(GstTracerHookFunction) do_push_buffer_pre);
|
||||
G_CALLBACK (do_push_buffer_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-push-post",
|
||||
(GstTracerHookFunction) do_push_buffer_post);
|
||||
G_CALLBACK (do_push_buffer_post));
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-pre",
|
||||
(GstTracerHookFunction) do_push_buffer_list_pre);
|
||||
G_CALLBACK (do_push_buffer_list_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-push-list-post",
|
||||
(GstTracerHookFunction) do_push_buffer_list_post);
|
||||
G_CALLBACK (do_push_buffer_list_post));
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-pre",
|
||||
(GstTracerHookFunction) do_pull_range_pre);
|
||||
G_CALLBACK (do_pull_range_pre));
|
||||
gst_tracer_register_hook (tracer, "pad-pull-range-post",
|
||||
(GstTracerHookFunction) do_pull_range_post);
|
||||
G_CALLBACK (do_pull_range_post));
|
||||
gst_tracer_register_hook (tracer, "pad-push-event-pre",
|
||||
(GstTracerHookFunction) do_push_event_pre);
|
||||
G_CALLBACK (do_push_event_pre));
|
||||
gst_tracer_register_hook (tracer, "element-post-message-pre",
|
||||
(GstTracerHookFunction) do_post_message_pre);
|
||||
G_CALLBACK (do_post_message_pre));
|
||||
gst_tracer_register_hook (tracer, "element-query-pre",
|
||||
(GstTracerHookFunction) do_query_pre);
|
||||
G_CALLBACK (do_query_pre));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue