sys/oss/gstosssink.c: get_delay() may return values lower than 0. In those cases, we should not actually cast to *uns...

Original commit message from CVS:
* sys/oss/gstosssink.c: (gst_osssink_get_delay),
(gst_osssink_get_time):
get_delay() may return values lower than 0. In those cases, we
should not actually cast to *unsigned* int64, that will break
stuff horribly. In my case, it screwed up A/V sync in movies
in totem rather badly.
This commit is contained in:
Ronald S. Bultje 2004-03-07 02:09:45 +00:00
parent 89bbfdc368
commit bc6e4f585c
2 changed files with 14 additions and 2 deletions

View file

@ -1,3 +1,12 @@
2004-03-06 Ronald Bultje <rbultje@ronald.bitfreak.net>
* sys/oss/gstosssink.c: (gst_osssink_get_delay),
(gst_osssink_get_time):
get_delay() may return values lower than 0. In those cases, we
should not actually cast to *unsigned* int64, that will break
stuff horribly. In my case, it screwed up A/V sync in movies
in totem rather badly.
2004-03-06 Christophe Fergeau <teuf@gnome.org> 2004-03-06 Christophe Fergeau <teuf@gnome.org>
* ext/faac/gstfaac.c: (gst_faac_chain): * ext/faac/gstfaac.c: (gst_faac_chain):

View file

@ -257,7 +257,7 @@ gst_osssink_sinkconnect (GstPad *pad, const GstCaps *caps)
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;
} }
static inline gint64 static inline gint
gst_osssink_get_delay (GstOssSink *osssink) gst_osssink_get_delay (GstOssSink *osssink)
{ {
gint delay = 0; gint delay = 0;
@ -280,6 +280,7 @@ gst_osssink_get_delay (GstOssSink *osssink)
delay = (info.fragstotal * info.fragsize) - info.bytes; delay = (info.fragstotal * info.fragsize) - info.bytes;
} }
} }
return delay; return delay;
} }
@ -298,7 +299,9 @@ gst_osssink_get_time (GstClock *clock, gpointer data)
/* sometimes delay is bigger than the number of bytes sent to the device, /* sometimes delay is bigger than the number of bytes sent to the device,
* which screws up this calculation, we assume that everything is still * which screws up this calculation, we assume that everything is still
* in the device then */ * in the device then */
if (((guint64)delay) > osssink->handled) { if (delay < 0) {
delay = 0;
} else if (((guint64) delay) > osssink->handled) {
delay = osssink->handled; delay = osssink->handled;
} }
res = (osssink->handled - delay) * GST_SECOND / GST_OSSELEMENT (osssink)->bps; res = (osssink->handled - delay) * GST_SECOND / GST_OSSELEMENT (osssink)->bps;