From 3895e431bd8e894b060c514f89618d7c74a84dfa Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 1 May 2014 10:37:18 -0400 Subject: [PATCH] basesink: Always render prepared buffer Currently, if prepare() takes too much time, we skip the call to render(). The side effect of this, is that we endup starving the render(). The solution in this patch is to always render frames that are on time before prepare() is executed. This will maximize the number of frames we display and smoothly degrade the rendering performance. https://bugzilla.gnome.org/show_bug.cgi?id=729335 --- libs/gst/base/gstbasesink.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 5d05077..2f8ceac 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -3273,7 +3273,7 @@ gst_base_sink_chain_unlocked (GstBaseSink * basesink, GstPad * pad, GstSegment *segment; GstBuffer *sync_buf; gint do_qos; - gboolean late, step_end; + gboolean late, step_end, prepared = FALSE; if (G_UNLIKELY (basesink->flushing)) goto flushing; @@ -3347,11 +3347,15 @@ gst_base_sink_chain_unlocked (GstBaseSink * basesink, GstPad * pad, gst_base_sink_get_sync_times (basesink, obj, &sstart, &sstop, &rstart, &rstop, &rnext, &do_sync, &stepped, current, &step_end); - if (!stepped && syncable && do_sync) + if (G_UNLIKELY (stepped)) + goto dropped; + + if (syncable && do_sync) late = gst_base_sink_is_too_late (basesink, obj, rstart, rstop, GST_CLOCK_EARLY, 0, FALSE); - if (late) + + if (G_UNLIKELY (late)) goto dropped; if (!is_list) { @@ -3367,6 +3371,8 @@ gst_base_sink_chain_unlocked (GstBaseSink * basesink, GstPad * pad, goto prepare_failed; } } + + prepared = TRUE; } again: @@ -3380,6 +3386,9 @@ again: if (G_UNLIKELY (ret != GST_FLOW_OK)) goto sync_failed; + /* Don't skip if prepare() was called on time */ + late = late && !prepared; + /* drop late buffers unconditionally, let's hope it's unlikely */ if (G_UNLIKELY (late)) goto dropped; -- 2.7.4