mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
tracer: use macros for hooks
Wrap the hook with a pre and post macro. This looks less intrusive than the previous version, although it is a little less optimized.
This commit is contained in:
parent
9d3975b5da
commit
e08fab7d5f
4 changed files with 50 additions and 66 deletions
|
@ -31,32 +31,20 @@ Hook api
|
||||||
--------
|
--------
|
||||||
e.g. gst_pad_push() would become:
|
e.g. gst_pad_push() would become:
|
||||||
|
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
static inline GstFlowReturn __gst_pad_push (GstPad * pad, GstBuffer * buffer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_pad_push (GstPad * pad, GstBuffer * buffer)
|
gst_pad_push (GstPad * pad, GstBuffer * buffer)
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
{
|
{
|
||||||
if (__tracer_enabled && __tracer_hook_is_used)
|
GstFlowReturn res;
|
||||||
gst_tracer_push_buffer_pre (pad, buffer);
|
|
||||||
GstFlowReturn res = __gst_pad_push (GstPad * pad, GstBuffer * buffer);
|
|
||||||
if (__tracer_enabled && __tracer_hook_is_used)
|
|
||||||
gst_tracer_push_buffer_post (pad, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline GstFlowReturn
|
|
||||||
__gst_pad_push (GstPad * pad, GstBuffer * buffer)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
|
||||||
|
|
||||||
return gst_pad_push_data (pad,
|
GST_TRACER_PAD_PUSH_PRE (pad, buffer);
|
||||||
|
res = gst_pad_push_data (pad,
|
||||||
GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH, buffer);
|
GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH, buffer);
|
||||||
|
GST_TRACER_PAD_PUSH_POST (pad, res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
TODO(ensonic): gcc has some magic for wrapping functions
|
TODO(ensonic): gcc has some magic for wrapping functions
|
||||||
|
@ -167,8 +155,6 @@ Problems / Open items
|
||||||
- when hooking into a timer, should we just have some predefined intervals?
|
- when hooking into a timer, should we just have some predefined intervals?
|
||||||
- how to trigger the shutdown processing?
|
- how to trigger the shutdown processing?
|
||||||
gst_deinit() (apps can call it from atexit())
|
gst_deinit() (apps can call it from atexit())
|
||||||
- how to share the quark table from gst/gstquark?
|
|
||||||
use a separate table in gst/gsttracers or add a getter to gst/gstquark
|
|
||||||
- how to chain tracers (use the rank?)
|
- how to chain tracers (use the rank?)
|
||||||
e.g. how can the stats tracer get data from rusage/mallinfo tracers
|
e.g. how can the stats tracer get data from rusage/mallinfo tracers
|
||||||
or should all tracers just log and we would use a gst-stats tool to collect
|
or should all tracers just log and we would use a gst-stats tool to collect
|
||||||
|
@ -183,3 +169,5 @@ Try it
|
||||||
GST_DEBUG="GST_REG*:4,GST_TRACER:4,log:7" GST_TRACE=log gst-launch-1.0 fakesrc num-buffers=10 ! fakesink
|
GST_DEBUG="GST_REG*:4,GST_TRACER:4,log:7" GST_TRACE=log gst-launch-1.0 fakesrc num-buffers=10 ! fakesink
|
||||||
- traces for buffer flow in TRACE level and default category
|
- traces for buffer flow in TRACE level and default category
|
||||||
|
|
||||||
|
GST_DEBUG="GST_REG*:4,GST_TRACER:4" GST_TRACE=stats gst-launch-1.0 fakesrc num-buffers=10 ! queue ! fakesink
|
||||||
|
- print some pipeline stats on exit
|
||||||
|
|
47
gst/gstpad.c
47
gst/gstpad.c
|
@ -4443,35 +4443,20 @@ not_linked:
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
static inline GstFlowReturn __gst_pad_push (GstPad * pad, GstBuffer * buffer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_pad_push (GstPad * pad, GstBuffer * buffer)
|
gst_pad_push (GstPad * pad, GstBuffer * buffer)
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
{
|
{
|
||||||
const gboolean trace = gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS);
|
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
|
|
||||||
if (trace)
|
|
||||||
gst_tracer_push_buffer_pre (gst_util_get_timestamp (), pad, buffer);
|
|
||||||
res = __gst_pad_push (pad, buffer);
|
|
||||||
if (trace)
|
|
||||||
gst_tracer_push_buffer_post (gst_util_get_timestamp (), pad, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline GstFlowReturn
|
|
||||||
__gst_pad_push (GstPad * pad, GstBuffer * buffer)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
|
||||||
|
|
||||||
return gst_pad_push_data (pad,
|
GST_TRACER_PAD_PUSH_PRE (pad, buffer);
|
||||||
|
res = gst_pad_push_data (pad,
|
||||||
GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH, buffer);
|
GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH, buffer);
|
||||||
|
GST_TRACER_PAD_PUSH_POST (pad, res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4498,36 +4483,20 @@ __gst_pad_push (GstPad * pad, GstBuffer * buffer)
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
static inline GstFlowReturn __gst_pad_push_list (GstPad * pad,
|
|
||||||
GstBufferList * list);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_pad_push_list (GstPad * pad, GstBufferList * list)
|
gst_pad_push_list (GstPad * pad, GstBufferList * list)
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
|
||||||
{
|
{
|
||||||
const gboolean trace = gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS);
|
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
|
|
||||||
if (trace)
|
|
||||||
gst_tracer_push_buffer_list_pre (gst_util_get_timestamp (), pad, list);
|
|
||||||
res = __gst_pad_push_list (pad, list);
|
|
||||||
if (trace)
|
|
||||||
gst_tracer_push_buffer_list_post (gst_util_get_timestamp (), pad, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline GstFlowReturn
|
|
||||||
__gst_pad_push_list (GstPad * pad, GstBufferList * list)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER_LIST (list), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_IS_BUFFER_LIST (list), GST_FLOW_ERROR);
|
||||||
|
|
||||||
return gst_pad_push_data (pad,
|
GST_TRACER_PAD_PUSH_LIST_PRE (pad, list);
|
||||||
|
res = gst_pad_push_data (pad,
|
||||||
GST_PAD_PROBE_TYPE_BUFFER_LIST | GST_PAD_PROBE_TYPE_PUSH, list);
|
GST_PAD_PROBE_TYPE_BUFFER_LIST | GST_PAD_PROBE_TYPE_PUSH, list);
|
||||||
|
GST_TRACER_PAD_PUSH_LIST_POST (pad, res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
|
|
@ -295,7 +295,7 @@ dispatch (GstTracerHookId id, guint64 ts, GstStructure * s)
|
||||||
|
|
||||||
/* tracing hooks */
|
/* tracing hooks */
|
||||||
void
|
void
|
||||||
gst_tracer_push_buffer_pre (guint64 ts, GstPad * pad, GstBuffer * buffer)
|
gst_tracer_push_pre (guint64 ts, GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
||||||
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_PRE),
|
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_PRE),
|
||||||
|
@ -304,7 +304,7 @@ gst_tracer_push_buffer_pre (guint64 ts, GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_tracer_push_buffer_post (guint64 ts, GstPad * pad, GstFlowReturn res)
|
gst_tracer_push_post (guint64 ts, GstPad * pad, GstFlowReturn res)
|
||||||
{
|
{
|
||||||
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
||||||
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_POST),
|
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_POST),
|
||||||
|
@ -313,7 +313,7 @@ gst_tracer_push_buffer_post (guint64 ts, GstPad * pad, GstFlowReturn res)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_tracer_push_buffer_list_pre (guint64 ts, GstPad * pad, GstBufferList * list)
|
gst_tracer_push_list_pre (guint64 ts, GstPad * pad, GstBufferList * list)
|
||||||
{
|
{
|
||||||
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
||||||
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_LIST_PRE),
|
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_LIST_PRE),
|
||||||
|
@ -322,7 +322,7 @@ gst_tracer_push_buffer_list_pre (guint64 ts, GstPad * pad, GstBufferList * list)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_tracer_push_buffer_list_post (guint64 ts, GstPad * pad, GstFlowReturn res)
|
gst_tracer_push_list_post (guint64 ts, GstPad * pad, GstFlowReturn res)
|
||||||
{
|
{
|
||||||
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
|
||||||
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_LIST_POST),
|
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_LIST_POST),
|
||||||
|
|
|
@ -105,10 +105,37 @@ gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type
|
||||||
|
|
||||||
gboolean gst_tracer_is_enabled (GstTracerHookId id);
|
gboolean gst_tracer_is_enabled (GstTracerHookId id);
|
||||||
|
|
||||||
void gst_tracer_push_buffer_pre (guint64 ts, GstPad *pad, GstBuffer *buffer);
|
void gst_tracer_push_pre (guint64 ts, GstPad *pad, GstBuffer *buffer);
|
||||||
void gst_tracer_push_buffer_post (guint64 ts, GstPad *pad, GstFlowReturn res);
|
void gst_tracer_push_post (guint64 ts, GstPad *pad, GstFlowReturn res);
|
||||||
void gst_tracer_push_buffer_list_pre (guint64 ts, GstPad * pad, GstBufferList * list);
|
void gst_tracer_push_list_pre (guint64 ts, GstPad * pad, GstBufferList * list);
|
||||||
void gst_tracer_push_buffer_list_post (guint64 ts, GstPad * pad, GstFlowReturn res);
|
void gst_tracer_push_list_post (guint64 ts, GstPad * pad, GstFlowReturn res);
|
||||||
|
|
||||||
|
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer) G_STMT_START{ \
|
||||||
|
if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
|
||||||
|
gst_tracer_push_pre (gst_util_get_timestamp (), pad, buffer); \
|
||||||
|
}G_STMT_END
|
||||||
|
|
||||||
|
#define GST_TRACER_PAD_PUSH_POST(pad, res) G_STMT_START{ \
|
||||||
|
if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
|
||||||
|
gst_tracer_push_post (gst_util_get_timestamp (), pad, res); \
|
||||||
|
}G_STMT_END
|
||||||
|
|
||||||
|
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list) G_STMT_START{ \
|
||||||
|
if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
|
||||||
|
gst_tracer_push_list_pre (gst_util_get_timestamp (), pad, list); \
|
||||||
|
}G_STMT_END
|
||||||
|
|
||||||
|
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res) G_STMT_START{ \
|
||||||
|
if (gst_tracer_is_enabled (GST_TRACER_HOOK_ID_BUFFERS)) \
|
||||||
|
gst_tracer_push_list_post (gst_util_get_timestamp (), pad, res); \
|
||||||
|
}G_STMT_END
|
||||||
|
|
||||||
|
#else /* !GST_DISABLE_GST_DEBUG */
|
||||||
|
|
||||||
|
#define GST_TRACER_PAD_PUSH_PRE(pad, buffer)
|
||||||
|
#define GST_TRACER_PAD_PUSH_POST(pad, res)
|
||||||
|
#define GST_TRACER_PAD_PUSH_LIST_PRE(pad, list)
|
||||||
|
#define GST_TRACER_PAD_PUSH_LIST_POST(pad, res)
|
||||||
|
|
||||||
#endif /* GST_DISABLE_GST_DEBUG */
|
#endif /* GST_DISABLE_GST_DEBUG */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue