From 9941d3f0a260317e4f555d538b6b0f04296a1be1 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sun, 12 Dec 2010 01:39:06 +1100 Subject: [PATCH] deinterlace: Avoid infinite loop draining frames When the pipeline is flushed just as we're draining history, don't loop infinitely, just discard the history and abort. --- gst/deinterlace/gstdeinterlace.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gst/deinterlace/gstdeinterlace.c b/gst/deinterlace/gstdeinterlace.c index 7d235e443c..37541547e0 100644 --- a/gst/deinterlace/gstdeinterlace.c +++ b/gst/deinterlace/gstdeinterlace.c @@ -593,6 +593,16 @@ gst_deinterlace_reset_history (GstDeinterlace * self, gboolean drop_all) { gint i; + if (!drop_all) { + GST_DEBUG_OBJECT (self, "Flushing history (count %d)", self->history_count); + while (self->history_count > 0) { + if (gst_deinterlace_output_frame (self, TRUE) != GST_FLOW_OK) { + /* Encountered error, or flushing -> skip and drop all remaining */ + drop_all = TRUE; + break; + } + } + } if (drop_all) { GST_DEBUG_OBJECT (self, "Resetting history (count %d)", self->history_count); @@ -603,10 +613,6 @@ gst_deinterlace_reset_history (GstDeinterlace * self, gboolean drop_all) self->field_history[i].buf = NULL; } } - } else { - GST_DEBUG_OBJECT (self, "Flushing history (count %d)", self->history_count); - while (self->history_count > 0) - gst_deinterlace_output_frame (self, TRUE); } memset (self->field_history, 0, GST_DEINTERLACE_MAX_FIELD_HISTORY * sizeof (GstDeinterlaceField));