From: Mathieu Duponchelle Date: Fri, 11 Jul 2014 16:29:17 +0000 (+0200) Subject: composition: Avoid emitting COMMITED like crazy X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72ec11ef06e7d8e708113ee9b7fa84e77aba9b5e;p=platform%2Fupstream%2Fgst-editing-services.git composition: Avoid emitting COMMITED like crazy Co-Authored by: Thibault Saunier --- diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c index eeca49d..4182587 100644 --- a/gnl/gnlcomposition.c +++ b/gnl/gnlcomposition.c @@ -1253,7 +1253,8 @@ ghost_event_probe_handler (GstPad * ghostpad G_GNUC_UNUSED, GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (comp), GST_DEBUG_GRAPH_SHOW_ALL, "eos-after-segment"); gst_pad_remove_probe (GNL_OBJECT_SRC (comp), priv->commited_probeid); - _add_emit_commited_and_restart_task (comp); + GST_FIXME_OBJECT (comp, "Check it we need to emit or not!!"); + _restart_task (comp, TRUE); } if (g_atomic_int_compare_and_exchange (&comp->priv->real_eos_seqnum, @@ -2193,38 +2194,39 @@ _emit_commited_signal_func (GnlComposition * comp) return G_SOURCE_REMOVE; } -static GstPadProbeReturn -_add_emit_commited_and_restart_task (GnlComposition * comp) +static void +_restart_task (GnlComposition * comp, gboolean emit_commit) { - GST_INFO_OBJECT (comp, "Setting up commited source and restarting task!"); + GST_INFO_OBJECT (comp, "Restarting task! (%semiting commit done?)", + emit_commit ? "" : "NOT "); - _add_gsource (comp, (GSourceFunc) _emit_commited_signal_func, comp, NULL, - G_PRIORITY_HIGH); + if (emit_commit) + _add_gsource (comp, (GSourceFunc) _emit_commited_signal_func, comp, NULL, + G_PRIORITY_HIGH); comp->priv->awaited_caps_seqnum = 0; comp->priv->commited_probeid = 0; gst_task_start (comp->task); - - return GST_PAD_PROBE_REMOVE; } -static GstPadProbeReturn -_commit_done_cb (GstPad * pad, GstPadProbeInfo * info, GnlComposition * comp) +static gboolean +_is_ready_to_restart_task (GnlComposition * comp, GstEvent * event) { - if (GST_EVENT_TYPE (info->data) == GST_EVENT_CAPS || - GST_EVENT_TYPE (info->data) == GST_EVENT_SEGMENT) { - gint seqnum = gst_event_get_seqnum (info->data); + if (GST_EVENT_TYPE (event) == GST_EVENT_CAPS || + GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) { + gint seqnum = gst_event_get_seqnum (event); if (comp->priv->awaited_caps_seqnum == seqnum) { GST_INFO_OBJECT (comp, "Got %s with proper seqnum" " done with stack reconfiguration %" GST_PTR_FORMAT, - GST_EVENT_TYPE_NAME (info->data), info->data); + GST_EVENT_TYPE_NAME (event), event); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (comp), GST_DEBUG_GRAPH_SHOW_ALL, "new-stack"); - return _add_emit_commited_and_restart_task (comp); + + return TRUE; } else { GST_ERROR_OBJECT (comp, "WARNING: Caps seqnum %i != wanted %i", @@ -2232,6 +2234,31 @@ _commit_done_cb (GstPad * pad, GstPadProbeInfo * info, GnlComposition * comp) } } + return FALSE; +} + +static GstPadProbeReturn +_commit_done_cb (GstPad * pad, GstPadProbeInfo * info, GnlComposition * comp) +{ + if (_is_ready_to_restart_task (comp, info->data)) { + _restart_task (comp, TRUE); + + return GST_PAD_PROBE_REMOVE; + } + + return GST_PAD_PROBE_OK; +} + +static GstPadProbeReturn +_stack_setup_done_cb (GstPad * pad, GstPadProbeInfo * info, + GnlComposition * comp) +{ + if (_is_ready_to_restart_task (comp, info->data)) { + _restart_task (comp, FALSE); + + return GST_PAD_PROBE_REMOVE; + } + return GST_PAD_PROBE_OK; }