From 818762e8fc5d3269417c90b1728baec3a17d5631 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Thu, 18 Aug 2011 23:52:37 +0000 Subject: [PATCH] tsdemux: do not send a new-segment on stream removal When a program is changed, stream_added is called which sets the need_newsegment to TRUE, then stream_removed is called, which calls the flush_pending_data, which checks for the newsegment and causes it to send a new-segment. We must not send the newsegment when flushing the pending data on the removed stream. We should only push it when flushing data on the newly added streams (after they finish parsing their PTS header) --- gst/mpegtsdemux/tsdemux.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 90c4edbdec..cf85c1e187 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -1217,13 +1217,24 @@ gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * bstream, static void gst_ts_demux_stream_removed (MpegTSBase * base, MpegTSBaseStream * bstream) { + GstTSDemux *demux = GST_TS_DEMUX (base); TSDemuxStream *stream = (TSDemuxStream *) bstream; if (stream->pad) { if (gst_pad_is_active (stream->pad)) { - GST_DEBUG_OBJECT (stream->pad, "Flushing out pending data"); + gboolean need_newsegment = demux->need_newsegment; + + /* We must not send the newsegment when flushing the pending data + on the removed stream. We should only push it when the newly added + stream finishes parsing its PTS */ + demux->need_newsegment = FALSE; + /* Flush out all data */ + GST_DEBUG_OBJECT (stream->pad, "Flushing out pending data"); gst_ts_demux_push_pending_data ((GstTSDemux *) base, stream); + + demux->need_newsegment = need_newsegment; + GST_DEBUG_OBJECT (stream->pad, "Pushing out EOS"); gst_pad_push_event (stream->pad, gst_event_new_eos ()); GST_DEBUG_OBJECT (stream->pad, "Deactivating and removing pad");