valve: Correctly set the DISCONT flag after dropping buffers
authorOlivier Crête <olivier.crete@collabora.co.uk>
Thu, 30 Sep 2010 20:22:04 +0000 (16:22 -0400)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 31 Dec 2010 00:51:11 +0000 (00:51 +0000)
plugins/elements/gstvalve.c

index 38bc52c..8754abd 100644 (file)
@@ -190,18 +190,19 @@ gst_valve_chain (GstPad * pad, GstBuffer * buffer)
 
   GST_OBJECT_LOCK (valve);
   drop = valve->drop;
-
-  if (!drop && valve->discont) {
-    buffer = gst_buffer_make_metadata_writable (buffer);
-    GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
-    valve->discont = FALSE;
-  }
   GST_OBJECT_UNLOCK (valve);
 
-  if (drop)
+  if (drop) {
     gst_buffer_unref (buffer);
-  else
+    valve->discont = TRUE;
+  } else {
+    if (valve->discont) {
+      buffer = gst_buffer_make_metadata_writable (buffer);
+      GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
+    }
+
     ret = gst_pad_push (valve->srcpad, buffer);
+  }
 
 
   /* Ignore errors if "drop" was changed while the thread was blocked