From d5a10b05c2918cfb3700db801d6b0095e2f48f89 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 24 Jul 2006 16:47:10 +0000 Subject: [PATCH] gst-libs/gst/audio/gstbaseaudiosink.c: Don't try to align a sample to an unknown value. Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_render): Don't try to align a sample to an unknown value. --- ChangeLog | 6 ++++++ gst-libs/gst/audio/gstbaseaudiosink.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 411ce18ba0..908063807b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-07-24 Wim Taymans + + * gst-libs/gst/audio/gstbaseaudiosink.c: + (gst_base_audio_sink_render): + Don't try to align a sample to an unknown value. + 2006-07-24 Wim Taymans * gst-libs/gst/audio/gstbaseaudiosink.c: diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index 48406d1d3d..07a386a8c9 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -593,6 +593,12 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) goto no_align; } + if (G_UNLIKELY (sink->next_sample == -1)) { + GST_DEBUG_OBJECT (sink, + "no align possible: no previous sample position known"); + goto no_align; + } + /* now try to align the sample to the previous one */ diff = ABS ((gint64) render_offset - (gint64) sink->next_sample); @@ -600,7 +606,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) * should be enough to compensate for various rounding errors in the timestamp * and sample offset position. We always resync if we got a discont anyway and * non-discont should be aligned by definition. */ - if (diff < ringbuf->spec.rate / DIFF_TOLERANCE) { + if (G_LIKELY (diff < ringbuf->spec.rate / DIFF_TOLERANCE)) { GST_DEBUG_OBJECT (sink, "align with prev sample, %" G_GINT64_FORMAT " < %lu", diff, ringbuf->spec.rate / DIFF_TOLERANCE);