aggregator: drop duplicated SEEK events
authorMathieu Duponchelle <mathieu@centricular.com>
Fri, 19 Jul 2019 15:28:25 +0000 (17:28 +0200)
committerMathieu Duponchelle <mathieu@centricular.com>
Fri, 19 Jul 2019 15:31:11 +0000 (17:31 +0200)
This is similar to what demuxers do, and necessary when multiple
sinks get seeked downstream of the aggregator: if we forward
duplicated seeks upstream, elements such as demuxers may drop
the flushing seeks, but return TRUE, aggregator then waits forever
for the flushing events.

Fixes #276

libs/gst/base/gstaggregator.c

index 28164cb..f0cc877 100644 (file)
@@ -2022,6 +2022,15 @@ gst_aggregator_do_seek (GstAggregator * self, GstEvent * event)
   flush = flags & GST_SEEK_FLAG_FLUSH;
 
   GST_OBJECT_LOCK (self);
+
+  if (gst_event_get_seqnum (event) == self->priv->next_seqnum) {
+    evdata.result = TRUE;
+    GST_DEBUG_OBJECT (self, "Dropping duplicated seek event with seqnum %d",
+        self->priv->next_seqnum);
+    GST_OBJECT_UNLOCK (self);
+    goto done;
+  }
+
   self->priv->next_seqnum = gst_event_get_seqnum (event);
 
   gst_segment_do_seek (&GST_AGGREGATOR_PAD (self->srcpad)->segment, rate, fmt,
@@ -2063,6 +2072,7 @@ gst_aggregator_do_seek (GstAggregator * self, GstEvent * event)
     }
   }
 
+done:
   GST_INFO_OBJECT (self, "seek done, result: %d", evdata.result);
 
   return evdata.result;