pad: Store sticky events even if the pad is flushing
authorSebastian Dröge <slomo@circular-chaos.org>
Mon, 27 May 2013 10:40:50 +0000 (12:40 +0200)
committerSebastian Dröge <slomo@circular-chaos.org>
Mon, 27 May 2013 10:40:50 +0000 (12:40 +0200)
But do this only for events that are not dropped by flushing,
i.e. do it only for everything except SEGMENT and EOS.

Without this we might drop a CAPS event if flushing happens
at an unfortunate time and nobody is resending the CAPS event.

https://bugzilla.gnome.org/show_bug.cgi?id=700806

gst/gstpad.c

index dc2d8e0..731fda2 100644 (file)
@@ -4451,13 +4451,20 @@ store_sticky_event (GstPad * pad, GstEvent * event)
   const gchar *name = NULL;
   gboolean insert = TRUE;
 
-  if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
+  type = GST_EVENT_TYPE (event);
+
+  /* Store all sticky events except SEGMENT/SEGMENT when we're flushing,
+   * otherwise they can be dropped and nothing would ever resend them.
+   * Only do that for activated pads though, everything else is a bug!
+   */
+  if (G_UNLIKELY (GST_PAD_MODE (pad) == GST_PAD_MODE_NONE
+          || (GST_PAD_IS_FLUSHING (pad) && (type == GST_EVENT_SEGMENT
+                  || type == GST_EVENT_EOS))))
     goto flushed;
 
   if (G_UNLIKELY (GST_PAD_IS_EOS (pad)))
     goto eos;
 
-  type = GST_EVENT_TYPE (event);
   if (type & GST_EVENT_TYPE_STICKY_MULTI)
     name = gst_structure_get_name (gst_event_get_structure (event));
 
@@ -4527,7 +4534,7 @@ store_sticky_event (GstPad * pad, GstEvent * event)
   if (type == GST_EVENT_EOS)
     GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_EOS);
 
-  return GST_FLOW_OK;
+  return GST_PAD_IS_FLUSHING (pad) ? GST_FLOW_FLUSHING : GST_FLOW_OK;
 
   /* ERRORS */
 flushed: