From ef8f0cdd9d4ddf89e620d343c4b9b73cee7bcbb5 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Wed, 11 Jan 2017 22:48:02 +1100 Subject: [PATCH] urisourcebin: Drop fake EOS if the pad got relinked If our pad got relinked in since the fake-EOS was sent to the pad, then drop the fake-EOS event. CID: 1398546 --- gst/playback/gsturisourcebin.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/gst/playback/gsturisourcebin.c b/gst/playback/gsturisourcebin.c index e35b68d..f87f8f8 100644 --- a/gst/playback/gsturisourcebin.c +++ b/gst/playback/gsturisourcebin.c @@ -1093,6 +1093,7 @@ demux_pad_events (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) if ((urisrc->pending_pads && link_pending_pad_to_output (urisrc, child_info->output_slot))) { + /* Found a new source pad to give this slot data - no need to send EOS */ GST_URI_SOURCE_BIN_UNLOCK (urisrc); goto done; } @@ -1268,16 +1269,18 @@ source_pad_event_probe (GstPad * pad, GstPadProbeInfo * info, slot = g_object_get_data (G_OBJECT (pad), "urisourcebin.slotinfo"); - gst_pad_push_event (slot->srcpad, gst_event_new_eos ()); + if (slot) { + if (slot->linked_info) { + /* Do not clear output slot yet. A new input was + * connected. We should just drop this EOS */ + GST_URI_SOURCE_BIN_UNLOCK (urisrc); + return GST_PAD_PROBE_DROP; + } - if (slot && slot->linked_info) { - /* Do not clear output slot yet */ - GST_URI_SOURCE_BIN_UNLOCK (urisrc); - return GST_PAD_PROBE_DROP; + gst_pad_push_event (slot->srcpad, gst_event_new_eos ()); + free_output_slot_async (urisrc, slot); } - free_output_slot_async (urisrc, slot); - /* FIXME: Only emit drained if all output pads are done and there's no * pending pads */ g_signal_emit (urisrc, gst_uri_source_bin_signals[SIGNAL_DRAINED], 0, NULL); @@ -1361,14 +1364,17 @@ pad_removed_cb (GstElement * element, GstPad * pad, GstURISourceBin * urisrc) if (!info->output_slot->is_eos && urisrc->pending_pads && link_pending_pad_to_output (urisrc, info->output_slot)) { + /* Found a new source pad to give this slot data - no need to send EOS */ GST_URI_SOURCE_BIN_UNLOCK (urisrc); return; } + /* Unlink this pad from its output slot and send a fake EOS event to drain the + * queue */ slot = info->output_slot; + slot->is_eos = TRUE; + slot->linked_info = NULL; - info->output_slot->is_eos = TRUE; - info->output_slot->linked_info = NULL; info->output_slot = NULL; GST_LOG_OBJECT (element, -- 2.7.4