+2007-11-28 Wim Taymans <wim.taymans@gmail.com>
+
+ * docs/gst/gstreamer-sections.txt:
+ * gst/gstclock.h:
+ * tests/check/gst/gstsystemclock.c: (GST_START_TEST),
+ (gst_systemclock_suite):
+ Start merging in the easy bits of #361155, the monotonic clock patch.
+ This one adds a few handy macros with docs and a testsuite.
+
2007-11-27 Wim Taymans <wim.taymans@gmail.com>
* plugins/elements/gstfilesink.c: (gst_file_sink_event):
*/
#define GST_NSECOND (GST_SECOND / G_GINT64_CONSTANT (1000000000))
+
+/**
+ * GST_TIME_AS_SECONDS:
+ * @time: the time
+ *
+ * Convert a #GstClockTime to seconds.
+ *
+ * Since: 0.10.16
+ */
+#define GST_TIME_AS_SECONDS(time) ((time) / GST_SECOND)
+/**
+ * GST_TIME_AS_MSECONDS:
+ *
+ * Convert a #GstClockTime to milliseconds (1/1000 of a second).
+ *
+ * Since: 0.10.16
+ */
+#define GST_TIME_AS_MSECONDS(time) ((time) / G_GINT64_CONSTANT (1000000))
+/**
+ * GST_TIME_TO_USECONDS:
+ *
+ * Convert a #GstClockTime to microseconds (1/1000000 of a second).
+ *
+ * Since: 0.10.16
+ */
+#define GST_TIME_AS_USECONDS(time) ((time) / G_GINT64_CONSTANT (1000))
+/**
+ * GST_TIME_TO_NSECONDS:
+ *
+ * Convert a #GstClockTime to nanoseconds (1/1000000000 of a second).
+ *
+ * Since: 0.10.16
+ */
+#define GST_TIME_AS_NSECONDS(time) (time)
+
/**
* GST_CLOCK_DIFF:
* @s: the first time
#include <gst/check/gstcheck.h>
+/* see if the defines make sense */
+GST_START_TEST (test_range)
+{
+ GstClockTime time, time2;
+
+ time = GST_SECOND;
+ fail_unless (time == G_GUINT64_CONSTANT (1000000000));
+
+ time2 = time / 1000;
+ fail_unless (time2 == 1000000);
+ fail_unless (time2 == GST_MSECOND);
+ fail_unless (time2 == GST_TIME_AS_USECONDS (time));
+
+ time2 = time / 1000000;
+ fail_unless (time2 == 1000);
+ fail_unless (time2 == GST_USECOND);
+ fail_unless (time2 == GST_TIME_AS_MSECONDS (time));
+}
+
+GST_END_TEST
GST_START_TEST (test_signedness)
{
GstClockTime time[] = { 0, 1, G_MAXUINT64 / GST_SECOND };
TCase *tc_chain = tcase_create ("waiting");
suite_add_tcase (s, tc_chain);
+ tcase_add_test (tc_chain, test_range);
tcase_add_test (tc_chain, test_signedness);
tcase_add_test (tc_chain, test_single_shot);
tcase_add_test (tc_chain, test_periodic_shot);