adder: ensure the discont flag is correct
authorStefan Sauer <ensonic@users.sf.net>
Fri, 10 Feb 2017 20:28:49 +0000 (21:28 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Fri, 10 Feb 2017 20:41:29 +0000 (21:41 +0100)
Previously it happened that reused buffer caused the discont to be on the wrong
buffers.

gst/adder/gstadder.c

index fe2d21a..6d45980 100644 (file)
@@ -1090,6 +1090,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
   gint rate, bps, bpf;
   gboolean had_mute = FALSE;
   gboolean is_eos = TRUE;
+  gboolean is_discont = FALSE;
 
   adder = GST_ADDER (user_data);
 
@@ -1111,7 +1112,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
     GstEvent *event;
 
     GST_INFO_OBJECT (adder->srcpad, "send pending stream start event");
-    /* FIXME: create id based on input ids, we can't use 
+    /* FIXME: create id based on input ids, we can't use
      * gst_pad_create_stream_id() though as that only handles 0..1 sink-pad
      */
     g_snprintf (s_id, sizeof (s_id), "adder-%08x", g_random_int ());
@@ -1144,7 +1145,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
           FALSE)) {
     GstEvent *event;
 
-    /* 
+    /*
      * When seeking we set the start and stop positions as given in the seek
      * event. We also adjust offset & timestamp accordingly.
      * This basically ignores all newsegments sent by upstream.
@@ -1169,6 +1170,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
           "start:%" G_GINT64_FORMAT "  end:%" G_GINT64_FORMAT " failed",
           adder->segment.start, adder->segment.stop);
     }
+    is_discont = TRUE;
   }
 
   /* get available bytes for reading, this can be 0 which could mean empty
@@ -1459,6 +1461,11 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
     GST_BUFFER_OFFSET_END (outbuf) = adder->offset;
     GST_BUFFER_DURATION (outbuf) = adder->segment.position - next_timestamp;
   }
+  if (is_discont) {
+    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
+  } else {
+    GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DISCONT);
+  }
 
   adder->offset = next_offset;
   adder->segment.position = next_timestamp;