From fe4dc610e61c71acd8747e8bc1fea0630a4bfcf4 Mon Sep 17 00:00:00 2001 From: Patricia Muscalu Date: Thu, 12 May 2016 14:43:43 +0200 Subject: [PATCH] auparse: Fix sticky event misordering warning Make sure that src pad has caps before sending segment event. https://bugzilla.gnome.org/show_bug.cgi?id=766359 --- gst/auparse/gstauparse.c | 21 +++++++++++++++------ gst/auparse/gstauparse.h | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gst/auparse/gstauparse.c b/gst/auparse/gstauparse.c index db5b684..b814ad8 100644 --- a/gst/auparse/gstauparse.c +++ b/gst/auparse/gstauparse.c @@ -419,7 +419,6 @@ gst_au_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) gint64 timestamp; gint64 duration; gint64 offset; - GstSegment segment; auparse = GST_AU_PARSE (parent); @@ -441,8 +440,11 @@ gst_au_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) if (ret != GST_FLOW_OK) goto out; - gst_segment_init (&segment, GST_FORMAT_TIME); - gst_pad_push_event (auparse->srcpad, gst_event_new_segment (&segment)); + if (auparse->need_segment) { + gst_pad_push_event (auparse->srcpad, + gst_event_new_segment (&auparse->segment)); + auparse->need_segment = FALSE; + } } avail = gst_adapter_available (auparse->adapter); @@ -688,7 +690,6 @@ gst_au_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) { gint64 start, stop, offset = 0; GstSegment segment; - GstEvent *new_event = NULL; /* some debug output */ gst_event_copy_segment (event, &segment); @@ -720,9 +721,17 @@ gst_au_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_segment_init (&segment, GST_FORMAT_TIME); segment.start = segment.time = start; segment.stop = stop; - new_event = gst_event_new_segment (&segment); - ret = gst_pad_push_event (auparse->srcpad, new_event); + gst_segment_copy_into (&segment, &auparse->segment); + + if (!gst_pad_has_current_caps (auparse->srcpad)) { + auparse->need_segment = TRUE; + ret = TRUE; + } else { + auparse->need_segment = FALSE; + ret = gst_pad_push_event (auparse->srcpad, + gst_event_new_segment (&segment)); + } auparse->buffer_offset = offset; diff --git a/gst/auparse/gstauparse.h b/gst/auparse/gstauparse.h index 6d8f35a..97a0995 100644 --- a/gst/auparse/gstauparse.h +++ b/gst/auparse/gstauparse.h @@ -53,7 +53,8 @@ struct _GstAuParse { GstAdapter *adapter; - /* GstSegment segment; */ + GstSegment segment; + gboolean need_segment; gint64 offset; /* where sample data starts */ gint64 buffer_offset; -- 2.7.4