diff options
author | Jan Schmidt <jan@centricular.com> | 2018-02-16 01:49:57 +1100 |
---|---|---|
committer | Jan Schmidt <jan@centricular.com> | 2018-02-16 17:02:31 +1100 |
commit | d61066e6b5233576c9bc1f775ce6959787188bce (patch) | |
tree | 64a1089f2b1bf651213c153c00ed9b0952e20ed7 /gst/multifile | |
parent | fea8aadcf163cb2fd04bc20fe1ec0c5c504f5c44 (diff) | |
download | gstreamer-plugins-good-d61066e6b5233576c9bc1f775ce6959787188bce.tar.gz |
splitmuxsrc: Improve not-linked handling.
Don't report not-linked unless all pads have
returned not-linked.
Diffstat (limited to 'gst/multifile')
-rw-r--r-- | gst/multifile/gstsplitmuxsrc.c | 33 | ||||
-rw-r--r-- | gst/multifile/gstsplitmuxsrc.h | 2 |
2 files changed, 34 insertions, 1 deletions
diff --git a/gst/multifile/gstsplitmuxsrc.c b/gst/multifile/gstsplitmuxsrc.c index 7f1ed653f..ad246e3b3 100644 --- a/gst/multifile/gstsplitmuxsrc.c +++ b/gst/multifile/gstsplitmuxsrc.c @@ -259,6 +259,7 @@ gst_splitmux_src_dispose (GObject * object) gst_element_remove_pad (GST_ELEMENT (splitmux), pad); } g_list_free (splitmux->pads); + splitmux->n_pads = 0; splitmux->pads = NULL; SPLITMUX_SRC_PADS_UNLOCK (splitmux); @@ -522,6 +523,22 @@ gst_splitmux_handle_buffer (GstSplitMuxSrc * splitmux, return ret; } +static guint +count_not_linked (GstSplitMuxSrc * splitmux) +{ + GList *cur; + guint ret = 0; + + for (cur = g_list_first (splitmux->pads); + cur != NULL; cur = g_list_next (cur)) { + SplitMuxSrcPad *splitpad = (SplitMuxSrcPad *) (cur->data); + if (GST_PAD_LAST_FLOW_RETURN (splitpad) == GST_FLOW_NOT_LINKED) + ret++; + } + + return ret; +} + static void gst_splitmux_pad_loop (GstPad * pad) { @@ -562,8 +579,21 @@ gst_splitmux_pad_loop (GstPad * pad) /* Stop immediately on error or flushing */ GST_INFO_OBJECT (splitpad, "Stopping due to pad_push() result %d", ret); gst_pad_pause_task (pad); - if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED) { + if (ret < GST_FLOW_EOS) { GST_ELEMENT_FLOW_ERROR (splitmux, ret); + } else if (ret == GST_FLOW_NOT_LINKED) { + gboolean post_error; + guint n_notlinked; + + /* Only post not-linked if all pads are not-linked */ + SPLITMUX_SRC_PADS_LOCK (splitmux); + n_notlinked = count_not_linked (splitmux); + post_error = (splitmux->pads_complete + && n_notlinked == splitmux->n_pads); + SPLITMUX_SRC_PADS_UNLOCK (splitmux); + + if (post_error) + GST_ELEMENT_FLOW_ERROR (splitmux, ret); } } } @@ -837,6 +867,7 @@ gst_splitmux_find_output_pad (GstSplitMuxPartReader * part, GstPad * pad, target = g_object_new (SPLITMUX_TYPE_SRC_PAD, "name", pad_name, "direction", GST_PAD_SRC, NULL); splitmux->pads = g_list_prepend (splitmux->pads, target); + splitmux->n_pads++; gst_pad_set_active (target, TRUE); diff --git a/gst/multifile/gstsplitmuxsrc.h b/gst/multifile/gstsplitmuxsrc.h index c234c9029..96e605c94 100644 --- a/gst/multifile/gstsplitmuxsrc.h +++ b/gst/multifile/gstsplitmuxsrc.h @@ -55,6 +55,8 @@ struct _GstSplitMuxSrc gboolean pads_complete; GMutex pads_lock; GList *pads; /* pads_lock */ + guint n_pads; + guint n_notlinked; GstClockTime total_duration; GstSegment play_segment; |