+2007-11-28 Stefan Kost <ensonic@users.sf.net>
+
+ * configure.ac:
+ * gst/gstdebugutils.c:
+ * gst/gstinfo.c:
+ Apply the posix-timer check from #361155. Conditionally use the posix
+ timer for logging. This gives better timestamp precission, less
+ overhead and no ntp jitter.
+
2007-11-28 Sebastian Dröge <slomo@circular-chaos.org>
* gst/gstminiobject.c: (gst_mini_object_get_type),
AC_FUNC_MMAP
AM_CONDITIONAL(HAVE_MMAP, test "x$ac_cv_func_mmap_fixed_mapped" = "xyes")
+dnl Check for POSIX timers
+AC_CHECK_FUNCS(clock_gettime, [], [
+ AC_CHECK_LIB(rt, clock_gettime, [
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
+ LIBS="$LIBS -lrt"
+ ])
+])
+
+AC_CACHE_CHECK(for posix timers, gst_cv_posix_timers,AC_TRY_RUN([
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+ int main() {
+#if defined(_POSIX_TIMERS) && _POSIX_TIMERS >= 0 && defined(CLOCK_REALTIME)
+ return 0;
+#else
+ return 1;
+#endif
+ }],gst_cv_posix_timers=yes,gst_cv_posix_timers=no))
+
+if test "$gst_cv_posix_timers" = "yes"; then
+ AC_DEFINE(HAVE_POSIX_TIMERS,1,[Have posix timers])
+ GST_HAVE_POSIX_TIMERS_DEFINE="#define GST_HAVE_POSIX_TIMERS 1"
+else
+ GST_HAVE_POSIX_TIMERS_DEFINE="#define GST_HAVE_POSIX_TIMERS 0"
+fi
+AC_SUBST(GST_HAVE_POSIX_TIMERS_DEFINE)
+AM_CONDITIONAL(GST_HAVE_POSIX_TIMERS, test "$gst_cv_posix_timers" = "yes")
+
+AC_CACHE_CHECK(for monotonic clock, gst_cv_monotonic_clock,AC_TRY_RUN([
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+ int main() {
+#if defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 && defined(CLOCK_MONOTONIC)
+ return 0;
+#else
+ return 1;
+#endif
+ }],gst_cv_monotonic_clock=yes,gst_cv_monotonic_clock=no))
+
+if test "$gst_cv_monotonic_clock" = "yes"; then
+ AC_DEFINE(HAVE_MONOTONIC_CLOCK,1,[Have a monotonic clock])
+ GST_HAVE_MONOTONIC_CLOCK_DEFINE="#define GST_HAVE_MONOTONIC_CLOCK 1"
+else
+ GST_HAVE_MONOTONIC_CLOCK_DEFINE="#define GST_HAVE_MONOTONIC_CLOCK 0"
+fi
+AC_SUBST(GST_HAVE_MONOTONIC_CLOCK_DEFINE)
+AM_CONDITIONAL(GST_HAVE_MONOTONIC_CLOCK, test "$gst_cv_monotonic_clock" = "yes")
+
dnl Check for a way to display the function name in debug output
AG_GST_CHECK_FUNCTION
const gchar * file_name)
{
gchar *ts_file_name = NULL;
- GTimeVal now;
GstClockTime elapsed;
g_return_if_fail (GST_IS_BIN (bin));
}
/* add timestamp */
- g_get_current_time (&now);
- elapsed = GST_TIMEVAL_TO_TIME (now) - _priv_gst_info_start_time;
+#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
ts_file_name =
g_strdup_printf ("%" GST_TIME_FORMAT "-%s", GST_TIME_ARGS (elapsed),
file_name);
void
_gst_debug_init (void)
{
- GTimeVal current;
-
gst_atomic_int_set (&__default_level, GST_LEVEL_DEFAULT);
gst_atomic_int_set (&__use_color, 1);
/* get time we started for debugging messages */
- g_get_current_time (¤t);
- _priv_gst_info_start_time = GST_TIMEVAL_TO_TIME (current);
+#ifdef HAVE_POSIX_TIMERS
+ {
+ struct timespec current;
+
+ clock_gettime (CLOCK_MONOTONIC, ¤t);
+ _priv_gst_info_start_time = GST_TIMESPEC_TO_TIME (current);
+ }
+#else
+ {
+ GTimeVal current;
+
+ g_get_current_time (¤t);
+ _priv_gst_info_start_time = GST_TIMEVAL_TO_TIME (current);
+ }
+#endif
#ifdef HAVE_PRINTF_EXTENSION
register_printf_function (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr,
gchar pidcolor[10];
const gchar *levelcolor;
gint pid;
- GTimeVal now;
GstClockTime elapsed;
gboolean free_color = TRUE;
gboolean free_obj = TRUE;
free_obj = FALSE;
}
- g_get_current_time (&now);
- elapsed = GST_TIMEVAL_TO_TIME (now) - _priv_gst_info_start_time;
+#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
/*
g_printerr ("%s (%p - %" GST_TIME_FORMAT ") %s%20s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n",