flacparse: On sink caps change restart parser
authorJochen Henneberg <jh@henneberg-systemdesign.com>
Wed, 5 Dec 2018 17:42:55 +0000 (18:42 +0100)
committerSebastian Dröge <slomo@coaxion.net>
Fri, 14 Dec 2018 09:22:33 +0000 (09:22 +0000)
Draining the parser is not enough here, on caps change we need to
reset it so it is ready to accept new caps.

gst/audioparsers/gstflacparse.c

index 90176af..2758d4c 100644 (file)
@@ -1883,11 +1883,26 @@ gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 static gboolean
 gst_flac_parse_set_sink_caps (GstBaseParse * parse, GstCaps * caps)
 {
+  GstCaps *current_caps;
+  GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
+
   /* If caps are changing, drain any pending frames we have so that afterwards
    * we can potentially accept a new stream that is starting with the FLAC
    * headers again. If headers appear in the middle of the stream we can't
    * detect them
    */
   gst_base_parse_drain (parse);
+
+  /* If the caps did really change we need to reset the parser */
+  current_caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (parse));
+  if (current_caps) {
+    if (!gst_caps_is_strictly_equal (caps, current_caps)) {
+      GST_DEBUG_OBJECT (flacparse, "Reset parser on sink pad caps change");
+      gst_flac_parse_stop (parse);
+      gst_flac_parse_start (parse);
+    }
+    gst_caps_unref (current_caps);
+  }
+
   return TRUE;
 }