Now hide the different clock stuff behind a macro.

Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstclock.h:
* gst/gstdebugutils.c:
* gst/gstinfo.c:
Now hide the different clock stuff behind a macro.
API: GST_GET_CURRENT_TIME
This commit is contained in:
Stefan Kost 2007-11-28 12:11:59 +00:00
parent ec080cd61b
commit fbf7086287
5 changed files with 41 additions and 47 deletions

View file

@ -1,3 +1,12 @@
2007-11-28 Stefan Kost <ensonic@users.sf.net>
* docs/gst/gstreamer-sections.txt:
* gst/gstclock.h:
* gst/gstdebugutils.c:
* gst/gstinfo.c:
Now hide the different clock stuff behind a macro.
API: GST_GET_CURRENT_TIME
2007-11-28 Stefan Kost <ensonic@users.sf.net>
* configure.ac:

View file

@ -320,6 +320,7 @@ GST_TIMEVAL_TO_TIME
GST_TIME_TO_TIMEVAL
GST_TIMESPEC_TO_TIME
GST_TIME_TO_TIMESPEC
GST_GET_CURRENT_TIME
GST_CLOCK_ENTRY_TRACE_NAME
GstClockEntry
GstClockCallback

View file

@ -198,6 +198,30 @@ G_STMT_START { \
(ts).tv_nsec = ((t) - (ts).tv_sec * GST_SECOND) / GST_NSECOND; \
} G_STMT_END
/**
* GST_GET_CURRENT_TIME:
* @now: GstClockTime variable that will get the current time
*
* Get the current time as a GstClockTime from the system.
*
* Since: 0.10.16
*/
#ifdef HAVE_POSIX_TIMERS
#define GST_GET_CURRENT_TIME(now) \
G_STMT_START { \
struct timespec _now; \
clock_gettime (CLOCK_MONOTONIC, &_now); \
now = GST_TIMESPEC_TO_TIME (_now); \
} G_STMT_END
#else
#define GST_GET_CURRENT_TIME(now) \
G_STMT_START { \
GTimeVal _now; \
g_get_current_time (&_now); \
now = GST_TIMEVAL_TO_TIME (_now); \
} G_STMT_END
#endif
/* timestamp debugging macros */
/**
* GST_TIME_FORMAT:

View file

@ -496,7 +496,7 @@ _gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
const gchar * file_name)
{
gchar *ts_file_name = NULL;
GstClockTime elapsed;
GstClockTime now, elapsed;
g_return_if_fail (GST_IS_BIN (bin));
@ -507,21 +507,8 @@ _gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
}
/* add timestamp */
#ifdef HAVE_POSIX_TIMERS
{
struct timespec now;
clock_gettime (CLOCK_MONOTONIC, &now);
elapsed = GST_TIMESPEC_TO_TIME (now) - _priv_gst_info_start_time;
}
#else
{
GTimeVal now;
g_get_current_time (&now);
elapsed = GST_TIMEVAL_TO_TIME (now) - _priv_gst_info_start_time;
}
#endif
GST_GET_CURRENT_TIME (now);
elapsed = GST_CLOCK_DIFF (now, _priv_gst_info_start_time);
ts_file_name =
g_strdup_printf ("%" GST_TIME_FORMAT "-%s", GST_TIME_ARGS (elapsed),
file_name);

View file

@ -281,21 +281,7 @@ _gst_debug_init (void)
gst_atomic_int_set (&__use_color, 1);
/* get time we started for debugging messages */
#ifdef HAVE_POSIX_TIMERS
{
struct timespec current;
clock_gettime (CLOCK_MONOTONIC, &current);
_priv_gst_info_start_time = GST_TIMESPEC_TO_TIME (current);
}
#else
{
GTimeVal current;
g_get_current_time (&current);
_priv_gst_info_start_time = GST_TIMEVAL_TO_TIME (current);
}
#endif
GST_GET_CURRENT_TIME (_priv_gst_info_start_time);
#ifdef HAVE_PRINTF_EXTENSION
register_printf_function (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr,
@ -640,7 +626,7 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
gchar pidcolor[10];
const gchar *levelcolor;
gint pid;
GstClockTime elapsed;
GstClockTime now, elapsed;
gboolean free_color = TRUE;
gboolean free_obj = TRUE;
static const gchar *levelcolormap[] = {
@ -679,21 +665,8 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
free_obj = FALSE;
}
#ifdef HAVE_POSIX_TIMERS
{
struct timespec now;
clock_gettime (CLOCK_MONOTONIC, &now);
elapsed = GST_TIMESPEC_TO_TIME (now) - _priv_gst_info_start_time;
}
#else
{
GTimeVal now;
g_get_current_time (&now);
elapsed = GST_TIMEVAL_TO_TIME (now) - _priv_gst_info_start_time;
}
#endif
GST_GET_CURRENT_TIME (now);
elapsed = GST_CLOCK_DIFF (now, _priv_gst_info_start_time);
/*
g_printerr ("%s (%p - %" GST_TIME_FORMAT ") %s%20s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n",