From 5d0f279feaa3f8c8a4a360853f4ef97237fc1487 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 1 Jun 2011 10:21:39 +0200 Subject: [PATCH] baseaudiosink: drop samples that are too late ... rather than having all of them rendered at 0 or subsequently aligned, likely inevitably leading to repeated resyncing. --- gst-libs/gst/audio/gstbaseaudiosink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index fea7a8e273..ffe449872e 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -1614,6 +1614,12 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf) render_stop = 0; } + /* in some clock slaving cases, all late samples end up at 0 first, + * and subsequent ones align with that until threshold exceeded, + * and then sync back to 0 and so on, so avoid that altogether */ + if (G_UNLIKELY (render_start == 0 && render_stop == 0)) + goto too_late; + /* and bring the time to the rate corrected offset in the buffer */ render_start = gst_util_uint64_scale_int (render_start, ringbuf->spec.rate, GST_SECOND); @@ -1738,6 +1744,11 @@ out_of_segment: ret = GST_FLOW_OK; goto done; } +too_late: + { + GST_DEBUG_OBJECT (sink, "dropping late sample"); + return GST_FLOW_OK; + } /* ERRORS */ payload_failed: {