tsdemux: Make sure old streams are drained before switching

Before we add any streams, make sure we drain all streams. This ensures
there's consistency that only "new" data will be pushed on buffers once
the new pads are added

https://bugzilla.gnome.org/show_bug.cgi?id=750402
This commit is contained in:
Edward Hervey 2015-09-15 18:20:38 +02:00 committed by Edward Hervey
parent 14e6d2d427
commit 7336294635

View file

@ -1704,7 +1704,7 @@ activate_pad_for_stream (GstTSDemux * tsdemux, TSDemuxStream * stream)
gst_pad_push_event (stream->pad, gst_event_new_gap (0, 0));
}
} else if (((MpegTSBaseStream *) stream)->stream_type != 0xff) {
GST_WARNING_OBJECT (tsdemux,
GST_DEBUG_OBJECT (tsdemux,
"stream %p (pid 0x%04x, type:0x%02x) has no pad", stream,
((MpegTSBaseStream *) stream)->pid,
((MpegTSBaseStream *) stream)->stream_type);
@ -1806,6 +1806,17 @@ gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program)
demux->segment_event = NULL;
}
/* DRAIN ALL STREAMS FIRST ! */
if (demux->previous_program) {
GList *tmp;
GST_DEBUG_OBJECT (demux, "Draining previous program");
for (tmp = demux->previous_program->stream_list; tmp; tmp = tmp->next) {
TSDemuxStream *stream = (TSDemuxStream *) tmp->data;
if (stream->pad)
gst_ts_demux_push_pending_data (demux, stream);
}
}
/* Add all streams, then fire no-more-pads */
for (tmp = program->stream_list; tmp; tmp = tmp->next) {
TSDemuxStream *stream = (TSDemuxStream *) tmp->data;