subparse/ssaparse: Fix event handling and order
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 10 May 2013 10:21:31 +0000 (12:21 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 10 May 2013 10:21:31 +0000 (12:21 +0200)
gst/subparse/gstssaparse.c
gst/subparse/gstsubparse.c

index f6fed8c..6fba00c 100644 (file)
@@ -83,8 +83,6 @@ gst_ssa_parse_init (GstSsaParse * parse)
       GST_DEBUG_FUNCPTR (gst_ssa_parse_src_event));
   gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
   gst_pad_use_fixed_caps (parse->srcpad);
-  gst_pad_set_caps (parse->srcpad,
-      gst_static_pad_template_get_caps (&src_templ));
 
   parse->ini = NULL;
   parse->framed = FALSE;
index b7ac148..c3f41c9 100644 (file)
@@ -1443,6 +1443,7 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
   GstFlowReturn ret = GST_FLOW_OK;
   GstCaps *caps = NULL;
   gchar *line, *subtitle;
+  gboolean need_tags = FALSE;
 
   if (self->first_buffer) {
     GstMapInfo map;
@@ -1467,7 +1468,19 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
       return GST_FLOW_EOS;
     }
     gst_caps_unref (caps);
+    need_tags = TRUE;
+  }
+
+  /* Push newsegment if needed */
+  if (self->need_segment) {
+    GST_LOG_OBJECT (self, "pushing newsegment event with %" GST_SEGMENT_FORMAT,
+        &self->segment);
+
+    gst_pad_push_event (self->srcpad, gst_event_new_segment (&self->segment));
+    self->need_segment = FALSE;
+  }
 
+  if (need_tags) {
     /* push tags */
     if (self->subtitle_codec != NULL) {
       GstTagList *tags;
@@ -1544,15 +1557,6 @@ gst_sub_parse_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * buf)
 
   self = GST_SUBPARSE (parent);
 
-  /* Push newsegment if needed */
-  if (self->need_segment) {
-    GST_LOG_OBJECT (self, "pushing newsegment event with %" GST_SEGMENT_FORMAT,
-        &self->segment);
-
-    gst_pad_push_event (self->srcpad, gst_event_new_segment (&self->segment));
-    self->need_segment = FALSE;
-  }
-
   ret = handle_buffer (self, buf);
 
   return ret;