[gst-devel] GstClockTime

Joshua N Pritikin vishnu at pobox.com
Wed Aug 7 23:07:02 CEST 2002

On Thu, Aug 08, 2002 at 08:59:23AM +0530, Joshua N Pritikin wrote:
> On Wed, Aug 07, 2002 at 10:00:48PM +0200, Ronald Bultje wrote:
> > GstClockTime is intended for 'time-from-start-of-movie', so it starts at
> > 0 and increments from there. If you want differences in time, you would
> > use gint64 (as you mentioned), not GstClocktime, which is intended only
> > for use as 'media timeoffset  from beginning of media'.
> If it is safe to cast from GstClockTime to GstClockTimeDiff then i don't
> understand why have two different types.

For example, how do i represent the current media time minus 1 second?

  GstClockTime tm = gst_clock_get_time (fv->player->clock) - GST_SECOND;
  if (tm < 0) tm = 0;

No, because we can underflow the unsigned math.  Does GstClockTimeDiff
help here?  i don't see how.  If the current time is less than 1 second
then we get some ridiculous number close to ~0LL.  So we need to do this:

  GstClockTime tm;
  if (gst_clock_get_time (fv->player->clock) < GST_SECOND)
    tm = 0;
    tm = gst_clock_get_time (fv->player->clock) - GST_SECOND;

or just loose the 64th bit:

  gint64 tm = ((gint64)gst_clock_get_time (fv->player->clock)) - ((gint64)GST_SECOND);
  if (tm < 0) tm = 0;

OK, but is anyone this careful?  Please look at gst-player ..
all clocks are immediately converted to signed and all math
is done in the signed convention.  So again, do we really need
all 64 bits?  Can't we manage with 63 bits?

Victory to the Divine Mother!!         after all,
  http://sahajayoga.org                  http://why-compete.org

More information about the gstreamer-devel mailing list