gst-libs/gst/audio/gstbaseaudiosink.c: Guard against over and underflows because of clock slaving.

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.
This commit is contained in:
Wim Taymans 2008-04-03 10:37:03 +00:00
parent 495f45b245
commit ce67ac6373
2 changed files with 17 additions and 3 deletions

View file

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

View 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 */