Start merging in the easy bits of #361155, the monotonic clock patch.

Original commit message from CVS:
* 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.
This commit is contained in:
Wim Taymans 2007-11-28 10:58:39 +00:00
parent 7797419321
commit 0e0caaf16a
4 changed files with 69 additions and 0 deletions

View file

@ -1,3 +1,12 @@
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):

View file

@ -311,6 +311,10 @@ GST_SECOND
GST_MSECOND
GST_USECOND
GST_NSECOND
GST_TIME_AS_SECONDS
GST_TIME_AS_MSECONDS
GST_TIME_AS_USECONDS
GST_TIME_AS_NSECONDS
GST_CLOCK_DIFF
GST_TIMEVAL_TO_TIME
GST_TIME_TO_TIMEVAL

View file

@ -106,6 +106,41 @@ typedef gpointer GstClockID;
*/
#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

View file

@ -21,6 +21,26 @@
#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 };
@ -386,6 +406,7 @@ gst_systemclock_suite (void)
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);