flacparse: Really post tags only after the initial newsegment event
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 6 Oct 2010 16:32:51 +0000 (18:32 +0200)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 8 Apr 2011 17:07:09 +0000 (18:07 +0100)
The first newsegment event will be send by the first call to
gst_base_parse_push_buffer() if necessary, posting the tags
before that is not a good idea. Instead do it from the
GstBaseParse::pre_push_buffer vfunc.

gst/audioparsers/gstflacparse.c

index a56fb41..e3411c4 100644 (file)
@@ -198,6 +198,8 @@ static GstFlowReturn gst_flac_parse_parse_frame (GstBaseParse * parse,
     GstBuffer * buffer);
 static gint gst_flac_parse_get_frame_overhead (GstBaseParse * parse,
     GstBuffer * buffer);
+static GstFlowReturn gst_flac_parse_pre_push_buffer (GstBaseParse * parse,
+    GstBuffer * buf);
 
 GST_BOILERPLATE (GstFlacParse, gst_flac_parse, GstBaseParse,
     GST_TYPE_BASE_PARSE);
@@ -244,6 +246,8 @@ gst_flac_parse_class_init (GstFlacParseClass * klass)
   baseparse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_flac_parse_parse_frame);
   baseparse_class->get_frame_overhead =
       GST_DEBUG_FUNCPTR (gst_flac_parse_get_frame_overhead);
+  baseparse_class->pre_push_buffer =
+      GST_DEBUG_FUNCPTR (gst_flac_parse_pre_push_buffer);
 }
 
 static void
@@ -1182,11 +1186,6 @@ push_headers:
   gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE (flacparse)), caps);
   gst_caps_unref (caps);
 
-  /* Push tags */
-  if (flacparse->tags)
-    gst_element_found_tags (GST_ELEMENT (flacparse),
-        gst_tag_list_copy (flacparse->tags));
-
   /* push header buffers; update caps, so when we push the first buffer the
    * negotiated caps will change to caps that include the streamheader field */
   for (l = flacparse->headers; l != NULL; l = l->next) {
@@ -1481,3 +1480,17 @@ gst_flac_parse_get_frame_overhead (GstBaseParse * parse, GstBuffer * buffer)
      * the second even less, so the total inaccuracy is negligible. */
     return 7;
 }
+
+static GstFlowReturn
+gst_flac_parse_pre_push_buffer (GstBaseParse * parse, GstBuffer * buf)
+{
+  GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
+
+  /* Push tags */
+  if (flacparse->tags) {
+    gst_element_found_tags (GST_ELEMENT (flacparse), flacparse->tags);
+    flacparse->tags = NULL;
+  }
+
+  return GST_FLOW_OK;
+}