adder: Collect incoming tag events and send them after newsegment. Fixes #588747
authorEdward Hervey <bilboed@bilboed.com>
Mon, 13 Jul 2009 07:28:54 +0000 (09:28 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Sun, 19 Jul 2009 08:49:17 +0000 (10:49 +0200)
gst/adder/gstadder.c
gst/adder/gstadder.h

index 3de9fa7..b51c2c6 100644 (file)
@@ -762,7 +762,7 @@ static gboolean
 gst_adder_sink_event (GstPad * pad, GstEvent * event)
 {
   GstAdder *adder;
-  gboolean ret;
+  gboolean ret = TRUE;
 
   adder = GST_ADDER (gst_pad_get_parent (pad));
 
@@ -783,6 +783,12 @@ gst_adder_sink_event (GstPad * pad, GstEvent * event)
       adder->flush_stop_pending = FALSE;
       GST_OBJECT_UNLOCK (adder->collect);
       break;
+    case GST_EVENT_TAG:
+      GST_OBJECT_LOCK (adder->collect);
+      /* collectpads is a pile of horse manure. */
+      adder->pending_events = g_list_append (adder->pending_events, event);
+      GST_OBJECT_UNLOCK (adder->collect);
+      goto beach;
     default:
       break;
   }
@@ -790,6 +796,7 @@ gst_adder_sink_event (GstPad * pad, GstEvent * event)
   /* now GstCollectPads can take care of the rest, e.g. EOS */
   ret = adder->collect_event (pad, event);
 
+beach:
   gst_object_unref (adder);
   return ret;
 }
@@ -1148,6 +1155,19 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
     }
   }
 
+  if (G_UNLIKELY (adder->pending_events)) {
+    GList *tmp = adder->pending_events;
+
+    while (tmp) {
+      GstEvent *ev = (GstEvent *) tmp->data;
+
+      gst_pad_push_event (adder->srcpad, ev);
+      tmp = g_list_next (tmp);
+    }
+    g_list_free (adder->pending_events);
+    adder->pending_events = NULL;
+  }
+
   /* set timestamps on the output buffer */
   GST_BUFFER_TIMESTAMP (outbuf) = adder->timestamp;
   GST_BUFFER_OFFSET (outbuf) = adder->offset;
index 422cf71..3832dfd 100644 (file)
@@ -92,6 +92,9 @@ struct _GstAdder {
   
   /* target caps */
   GstCaps *filter_caps;
+
+  /* Pending inline events */
+  GList *pending_events;
 };
 
 struct _GstAdderClass {