diff options
author | Mathieu Duponchelle <mathieu.duponchelle@opencreed.com> | 2014-05-07 16:18:40 +0200 |
---|---|---|
committer | Thibault Saunier <tsaunier@gnome.org> | 2014-05-07 19:06:45 +0200 |
commit | 94e3c11fbd7e7c9ea66347bb9a4636b94825c740 (patch) | |
tree | 73ddbf34107bca41aa96f3ee52649f17ae68968b | |
parent | 87413a0590132fe688b99d537123475c71e0e7c5 (diff) |
composition: Drop buffers until we get seeked
Make sure we don't let buffers pass before our entry
got correctly seeked and had a segment when updating
the pipeline
-rw-r--r-- | gnl/gnlcomposition.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c index 100e9bb..9bc7462 100644 --- a/gnl/gnlcomposition.c +++ b/gnl/gnlcomposition.c @@ -268,6 +268,8 @@ struct _GnlCompositionEntry /* handler id for block probe */ gulong probeid; gulong dataprobeid; + + gboolean seeked; }; static void @@ -1237,14 +1239,28 @@ pad_blocked (GstPad * pad, GstPadProbeInfo * info, GnlComposition * comp) static GstPadProbeReturn drop_data (GstPad * pad, GstPadProbeInfo * info, GnlCompositionEntry * entry) { - GnlCompositionPrivate *priv = entry->comp->priv; - /* When updating the pipeline, do not let data flowing */ - if (priv->stackvalid == FALSE || priv->childseek != NULL) + if (!GST_IS_EVENT (info->data)) { + GST_LOG_OBJECT (pad, "Dropping data while updating pipeline"); return GST_PAD_PROBE_DROP; + } else { + GstEvent *event = GST_EVENT (info->data); + + if (GST_EVENT_TYPE (event) == GST_EVENT_SEEK) { + entry->seeked = TRUE; + GST_DEBUG_OBJECT (pad, "Got SEEK event"); + } else if (entry->seeked == TRUE && + GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) { + entry->seeked = FALSE; + entry->dataprobeid = 0; - entry->dataprobeid = 0; - return GST_PAD_PROBE_REMOVE; + GST_DEBUG_OBJECT (pad, "Already seeked and got segment," + " removing probe"); + return GST_PAD_PROBE_REMOVE; + } + } + + return GST_PAD_PROBE_OK; } static inline void @@ -1327,8 +1343,9 @@ gnl_composition_ghost_pad_set_target (GnlComposition * comp, GstPad * target, if (!priv->toplevelentry->dataprobeid) { priv->toplevelentry->dataprobeid = gst_pad_add_probe (ptarget, - GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST, - (GstPadProbeCallback) drop_data, priv->toplevelentry, NULL); + GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | + GST_PAD_PROBE_TYPE_EVENT_BOTH, (GstPadProbeCallback) drop_data, + priv->toplevelentry, NULL); } /* remove event probe */ @@ -2256,8 +2273,9 @@ compare_relink_single_node (GnlComposition * comp, GNode * node, } if (!oldentry->dataprobeid) { oldentry->dataprobeid = gst_pad_add_probe (srcpad, - GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST, - (GstPadProbeCallback) drop_data, oldentry, NULL); + GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | + GST_PAD_PROBE_TYPE_EVENT_BOTH, (GstPadProbeCallback) drop_data, + oldentry, NULL); } } @@ -2413,8 +2431,9 @@ compare_deactivate_single_node (GnlComposition * comp, GNode * node, } if (entry && !entry->dataprobeid) { entry->dataprobeid = gst_pad_add_probe (srcpad, - GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST, - (GstPadProbeCallback) drop_data, entry, NULL); + GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | + GST_PAD_PROBE_TYPE_EVENT_BOTH, (GstPadProbeCallback) drop_data, entry, + NULL); } /* 2. If we have to modify or we have a parent, flush downstream @@ -2851,8 +2870,9 @@ object_pad_added (GnlObject * object G_GNUC_UNUSED, GstPad * pad, if (!entry->dataprobeid) { entry->dataprobeid = gst_pad_add_probe (pad, - GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST, - (GstPadProbeCallback) drop_data, entry, NULL); + GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | + GST_PAD_PROBE_TYPE_EVENT_BOTH, (GstPadProbeCallback) drop_data, entry, + NULL); } } |