summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2007-12-11 20:23:58 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2007-12-11 20:23:58 +0000
commit428a4e9669aaa24686bd3fdf052f37a81c4c95da (patch)
treed1cc86ef01df22d66b4d9da838a4938c6eaf3b21 /gst
parent9aca6f57c3877e5ef43ea0cb846862700aa9a954 (diff)
downloadgstreamer-428a4e9669aaa24686bd3fdf052f37a81c4c95da.tar.gz
Change GST_GET_TIMESTAMP into gst_util_get_timestamp and replace all uses as we don't have HAVE_POSIX_TIMERS in publi...
Original commit message from CVS: * docs/gst/gstreamer-sections.txt: * gst/gstclock.h: * gst/gstdebugutils.c: * gst/gstinfo.c: * gst/gstutils.c: * gst/gstutils.h: * libs/gst/base/gstbasesink.c: * tools/gst-launch.c: Change GST_GET_TIMESTAMP into gst_util_get_timestamp and replace all uses as we don't have HAVE_POSIX_TIMERS in public headers. Thanks Tim for spotting.
Diffstat (limited to 'gst')
-rw-r--r--gst/gstclock.h25
-rw-r--r--gst/gstdebugutils.c6
-rw-r--r--gst/gstinfo.c8
-rw-r--r--gst/gstutils.c27
-rw-r--r--gst/gstutils.h2
5 files changed, 36 insertions, 32 deletions
diff --git a/gst/gstclock.h b/gst/gstclock.h
index 9ec226076a..3c07d044ce 100644
--- a/gst/gstclock.h
+++ b/gst/gstclock.h
@@ -198,31 +198,6 @@ G_STMT_START { \
(ts).tv_nsec = ((t) - (ts).tv_sec * GST_SECOND) / GST_NSECOND; \
} G_STMT_END
-/**
- * GST_GET_TIMESTAMP:
- * @now: GstClockTime variable that will get the timestamp
- *
- * Get a timestamp as GstClockTime to be used for interval meassurements.
- * The timestamp should now be interpreted in any other way.
- *
- * Since: 0.10.16
- */
-#ifdef HAVE_POSIX_TIMERS
-#define GST_GET_TIMESTAMP(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_TIMESTAMP(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:
diff --git a/gst/gstdebugutils.c b/gst/gstdebugutils.c
index 0927eeebfc..71d383ebd6 100644
--- a/gst/gstdebugutils.c
+++ b/gst/gstdebugutils.c
@@ -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 now, elapsed;
+ GstClockTime elapsed;
g_return_if_fail (GST_IS_BIN (bin));
@@ -507,8 +507,8 @@ _gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
}
/* add timestamp */
- GST_GET_TIMESTAMP (now);
- elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time, now);
+ elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
+ gst_util_get_timestamp ());
ts_file_name =
g_strdup_printf ("%" GST_TIME_FORMAT "-%s", GST_TIME_ARGS (elapsed),
file_name);
diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 0ca33469fd..d7edcf5df9 100644
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
@@ -281,7 +281,7 @@ _gst_debug_init (void)
gst_atomic_int_set (&__use_color, 1);
/* get time we started for debugging messages */
- GST_GET_TIMESTAMP (_priv_gst_info_start_time);
+ _priv_gst_info_start_time = gst_util_get_timestamp ();
#ifdef HAVE_PRINTF_EXTENSION
register_printf_function (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr,
@@ -626,7 +626,7 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
gchar pidcolor[10];
const gchar *levelcolor;
gint pid;
- GstClockTime now, elapsed;
+ GstClockTime elapsed;
gboolean free_color = TRUE;
gboolean free_obj = TRUE;
static const gchar *levelcolormap[] = {
@@ -665,8 +665,8 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
free_obj = FALSE;
}
- GST_GET_TIMESTAMP (now);
- elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time, now);
+ elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
+ gst_util_get_timestamp ());
/*
g_printerr ("%s (%p - %" GST_TIME_FORMAT ") %s%20s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n",
diff --git a/gst/gstutils.c b/gst/gstutils.c
index 27bbe775c3..6425ff86e2 100644
--- a/gst/gstutils.c
+++ b/gst/gstutils.c
@@ -3327,3 +3327,30 @@ gst_type_register_static_full (GType parent_type,
return g_type_register_static (parent_type, type_name, &info, flags);
}
+
+
+/**
+ * gst_util_get_timestamp:
+ *
+ * Get a timestamp as GstClockTime to be used for interval meassurements.
+ * The timestamp should not be interpreted in any other way.
+ *
+ * Returns: the timestamp
+ *
+ * Since: 0.10.16
+ */
+G_GNUC_PURE GstClockTime
+gst_util_get_timestamp (void)
+{
+#ifdef HAVE_POSIX_TIMERS
+ struct timespec now;
+
+ clock_gettime (CLOCK_MONOTONIC, &now);
+ return GST_TIMESPEC_TO_TIME (now);
+#else
+ GTimeVal now;
+
+ g_get_current_time (&now);
+ return GST_TIMEVAL_TO_TIME (now);
+#endif
+}
diff --git a/gst/gstutils.h b/gst/gstutils.h
index 860bd873ee..dd438af890 100644
--- a/gst/gstutils.h
+++ b/gst/gstutils.h
@@ -689,6 +689,8 @@ GstElement * gst_parse_bin_from_description (const gchar * bin_descr
gboolean ghost_unconnected_pads,
GError ** err);
+GstClockTime gst_util_get_timestamp (void) G_GNUC_PURE;
+
G_END_DECLS
#endif /* __GST_UTILS_H__ */