Commit f8d7a2a0 authored by Jan Schmidt's avatar Jan Schmidt

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
parent 628af4f0
......@@ -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)
{
......
......@@ -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);
......
......@@ -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;
/* This is the first pad to move to the new part, activate it */
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 */
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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment