gst-libs/gst/audio/gstbaseaudiosink.c: Guard against over and underflows because...
authorWim Taymans <wim.taymans@gmail.com>
Thu, 3 Apr 2008 10:37:03 +0000 (10:37 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Thu, 3 Apr 2008 10:37:03 +0000 (10:37 +0000)
Original commit message from CVS:
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_skew_slaving), (gst_base_audio_sink_render):
Guard against over and underflows because of clock slaving.
When we are using our own clock, still compensate for any calibrations
that we might have done to our clock.

ChangeLog
gst-libs/gst/audio/gstbaseaudiosink.c

index 3402fd5..3ed65b1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2008-04-03  Wim Taymans  <wim.taymans@collabora.co.uk>
 
+       * gst-libs/gst/audio/gstbaseaudiosink.c:
+       (gst_base_audio_sink_skew_slaving), (gst_base_audio_sink_render):
+       Guard against over and underflows because of clock slaving.
+       When we are using our own clock, still compensate for any calibrations
+       that we might have done to our clock.
+
+2008-04-03  Wim Taymans  <wim.taymans@collabora.co.uk>
+
        * ext/theora/theoradec.c: (theora_handle_type_packet),
        (theora_dec_chain):
        Don't try to do anything fancy with the return code from pushing an
index 4bd5cfd..91ab492 100644 (file)
@@ -870,8 +870,9 @@ gst_base_audio_sink_skew_slaving (GstBaseAudioSink * sink,
   etime = gst_clock_get_time (GST_ELEMENT_CLOCK (sink));
   itime = gst_clock_get_internal_time (sink->provided_clock);
 
-  etime -= cexternal;
-  itime -= cinternal;
+  /* make sure we never go below 0 */
+  etime = etime > cexternal ? etime - cexternal : 0;
+  itime = itime > cinternal ? itime - cinternal : 0;
 
   skew = GST_CLOCK_DIFF (etime, itime);
   if (sink->priv->avg_skew == -1) {
@@ -896,7 +897,7 @@ gst_base_audio_sink_skew_slaving (GstBaseAudioSink * sink,
     GST_WARNING_OBJECT (sink,
         "correct clock skew %" G_GINT64_FORMAT " > %" G_GINT64_FORMAT,
         sink->priv->avg_skew, segtime2);
-    cinternal += segtime;
+    cexternal = cexternal > segtime ? cexternal - segtime : 0;
     sink->priv->avg_skew -= segtime;
 
     segsamples =
@@ -1138,6 +1139,11 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
     /* handle clock slaving */
     gst_base_audio_sink_handle_slaving (sink, render_start, render_stop,
         &render_start, &render_stop);
+  } else {
+    /* no slaving needed but we need to adapt to the clock calibration
+     * parameters */
+    gst_base_audio_sink_none_slaving (sink, render_start, render_stop,
+        &render_start, &render_stop);
   }
 
   /* and bring the time to the rate corrected offset in the buffer */