deinterlace: Avoid infinite loop draining frames
authorJan Schmidt <thaytan@noraisin.net>
Sat, 11 Dec 2010 14:39:06 +0000 (01:39 +1100)
committerJan Schmidt <jan.schmidt@oracle.com>
Sat, 11 Dec 2010 23:15:13 +0000 (10:15 +1100)
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

index 7d235e4..3754154 100644 (file)
@@ -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));