audioaggregator: Accept buffer with no data, but duration and gap flag
authorOlivier Crête <olivier.crete@collabora.com>
Thu, 13 Jul 2017 23:09:43 +0000 (19:09 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Sat, 21 Oct 2017 10:06:08 +0000 (12:06 +0200)
These are produced from GAP events by the base class.

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

gst-libs/gst/audio/gstaudioaggregator.c

index 24b71b7..8e0d485 100644 (file)
@@ -791,6 +791,18 @@ gst_audio_aggregator_queue_new_buffer (GstAudioAggregator * aagg,
   pad->priv->position = 0;
   pad->priv->size = gst_buffer_get_size (inbuf) / bpf;
 
+  if (pad->priv->size == 0) {
+    if (!GST_BUFFER_DURATION_IS_VALID (inbuf) ||
+        !GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
+      GST_WARNING_OBJECT (pad, "Dropping 0-sized buffer missing either a"
+          " duration or a GAP flag: %" GST_PTR_FORMAT, inbuf);
+      return FALSE;
+    }
+
+    pad->priv->size = gst_util_uint64_scale (GST_BUFFER_DURATION (inbuf), rate,
+        GST_SECOND);
+  }
+
   if (!GST_BUFFER_PTS_IS_VALID (inbuf)) {
     if (pad->priv->output_offset == -1)
       pad->priv->output_offset = aagg->priv->offset;