diff options
author | Jan Schmidt <jan@centricular.com> | 2016-09-29 04:50:25 +1000 |
---|---|---|
committer | Jan Schmidt <jan@centricular.com> | 2016-10-01 00:29:43 +1000 |
commit | 451f24598a59e7ef713c25a3a096a2213b0cfbec (patch) | |
tree | 729201c98b4b4548cc0641b0e47cd063f6eff5dc | |
parent | c78e3885dfa262036034b90ad8e4cf1e287c21f0 (diff) | |
download | gstreamer-plugins-good-451f24598a59e7ef713c25a3a096a2213b0cfbec.tar.gz |
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
-rw-r--r-- | gst/multifile/gstsplitmuxpartreader.c | 12 | ||||
-rw-r--r-- | gst/multifile/gstsplitmuxpartreader.h | 1 | ||||
-rw-r--r-- | gst/multifile/gstsplitmuxsrc.c | 30 |
3 files changed, 29 insertions, 14 deletions
diff --git a/gst/multifile/gstsplitmuxpartreader.c b/gst/multifile/gstsplitmuxpartreader.c index 5e98166d4..16d78bed7 100644 --- a/gst/multifile/gstsplitmuxpartreader.c +++ b/gst/multifile/gstsplitmuxpartreader.c @@ -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) { diff --git a/gst/multifile/gstsplitmuxpartreader.h b/gst/multifile/gstsplitmuxpartreader.h index 593d8ae02..95d920fc5 100644 --- a/gst/multifile/gstsplitmuxpartreader.h +++ b/gst/multifile/gstsplitmuxpartreader.h @@ -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); diff --git a/gst/multifile/gstsplitmuxsrc.c b/gst/multifile/gstsplitmuxsrc.c index 6cd9e1f6f..5fb7de698 100644 --- a/gst/multifile/gstsplitmuxsrc.c +++ b/gst/multifile/gstsplitmuxsrc.c @@ -931,21 +931,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; } |