summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2018-02-16 01:49:57 +1100
committerJan Schmidt <jan@centricular.com>2018-02-16 02:02:53 +1100
commit3b5b102d10f1a50acde488d4bcb5e10e3f5564f5 (patch)
treef0f56b8a91318ab67dc72c37fd49e5697c8dd384
parent45951e16c7a982a789561622322427e796daf684 (diff)
downloadgstreamer-plugins-good-3b5b102d10f1a50acde488d4bcb5e10e3f5564f5.tar.gz
splitmuxsrc: Improve not-linked handling.
Don't report not-linked unless all pads have returned not-linked.
-rw-r--r--gst/multifile/gstsplitmuxsrc.c33
-rw-r--r--gst/multifile/gstsplitmuxsrc.h2
2 files changed, 34 insertions, 1 deletions
diff --git a/gst/multifile/gstsplitmuxsrc.c b/gst/multifile/gstsplitmuxsrc.c
index b27cf00c9..6f89b37c7 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);
@@ -512,6 +513,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)
{
@@ -552,8 +569,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);
}
}
}
@@ -827,6 +857,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;