splitmuxsrc: Avoid stall when parts get out of sync

When one part moves ahead of the others - due to excessive
downstream queueing, or really small input files - then
we can end up activating parts more than once. That can lead to
effects like shutting down pad tasks prematurely.

https://bugzilla.gnome.org/show_bug.cgi?id=772138
This commit is contained in:
Jan Schmidt 2016-09-29 04:50:25 +10:00
parent 628af4f091
commit f8d7a2a0af
3 changed files with 28 additions and 13 deletions

View file

@ -1185,6 +1185,18 @@ gst_splitmux_part_reader_activate (GstSplitMuxPartReader * reader,
return TRUE;
}
gboolean
gst_splitmux_part_reader_is_active (GstSplitMuxPartReader * part)
{
gboolean ret;
SPLITMUX_PART_LOCK (part);
ret = part->active;
SPLITMUX_PART_UNLOCK (part);
return ret;
}
void
gst_splitmux_part_reader_deactivate (GstSplitMuxPartReader * reader)
{

View file

@ -103,6 +103,7 @@ gboolean gst_splitmux_part_is_eos (GstSplitMuxPartReader *reader);
gboolean gst_splitmux_part_reader_activate (GstSplitMuxPartReader *part, GstSegment *seg);
void gst_splitmux_part_reader_deactivate (GstSplitMuxPartReader *part);
gboolean gst_splitmux_part_reader_is_active (GstSplitMuxPartReader *part);
gboolean gst_splitmux_part_reader_src_query (GstSplitMuxPartReader *part, GstPad *src_pad, GstQuery * query);
void gst_splitmux_part_reader_set_start_offset (GstSplitMuxPartReader *part, GstClockTime offset);

View file

@ -955,21 +955,23 @@ gst_splitmux_end_of_part (GstSplitMuxSrc * splitmux, SplitMuxSrcPad * splitpad)
(GstPad *) (splitpad));
if (splitmux->cur_part != next_part) {
GstSegment tmp;
/* If moving backward into a new part, set stop
* to -1 to ensure we play the entire file - workaround
* a bug in qtdemux that misses bits at the end */
gst_segment_copy_into (&splitmux->play_segment, &tmp);
if (tmp.rate < 0)
tmp.stop = -1;
if (!gst_splitmux_part_reader_is_active (splitpad->reader)) {
GstSegment tmp;
/* If moving backward into a new part, set stop
* to -1 to ensure we play the entire file - workaround
* a bug in qtdemux that misses bits at the end */
gst_segment_copy_into (&splitmux->play_segment, &tmp);
if (tmp.rate < 0)
tmp.stop = -1;
/* This is the first pad to move to the new part, activate it */
/* This is the first pad to move to the new part, activate it */
GST_DEBUG_OBJECT (splitpad,
"First pad to change part. Activating part %d with seg %"
GST_SEGMENT_FORMAT, next_part, &tmp);
if (!gst_splitmux_part_reader_activate (splitpad->reader, &tmp))
goto error;
}
splitmux->cur_part = next_part;
GST_DEBUG_OBJECT (splitpad,
"First pad to change part. Activating part %d with seg %"
GST_SEGMENT_FORMAT, next_part, &tmp);
if (!gst_splitmux_part_reader_activate (splitpad->reader, &tmp))
goto error;
}
res = TRUE;
}