summaryrefslogtreecommitdiffstats
path: root/gst/switch/gstswitch.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/switch/gstswitch.c')
-rw-r--r--gst/switch/gstswitch.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/gst/switch/gstswitch.c b/gst/switch/gstswitch.c
index e7456dce..9201e084 100644
--- a/gst/switch/gstswitch.c
+++ b/gst/switch/gstswitch.c
@@ -314,6 +314,25 @@ gst_selector_pad_bufferalloc (GstPad * pad, guint64 offset,
return result;
}
+static gboolean
+gst_stream_selector_wait (GstStreamSelector * self, GstPad * pad)
+{
+ gboolean flushing;
+
+ GST_OBJECT_LOCK (self);
+
+ while (self->blocked)
+ g_cond_wait (self->blocked_cond, GST_OBJECT_GET_LOCK (self));
+
+ GST_OBJECT_UNLOCK (self);
+
+ GST_OBJECT_LOCK (pad);
+ flushing = GST_PAD_IS_FLUSHING (pad);
+ GST_OBJECT_UNLOCK (pad);
+
+ return flushing;
+}
+
static GstFlowReturn
gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
{
@@ -328,6 +347,9 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
selpad = GST_SELECTOR_PAD_CAST (pad);
seg = &selpad->segment;
+ if (gst_stream_selector_wait (sel, pad))
+ goto ignore;
+
active_sinkpad = gst_stream_selector_activate_sinkpad (sel, pad);
timestamp = GST_BUFFER_TIMESTAMP (buf);
@@ -368,7 +390,6 @@ ignore:
res = GST_FLOW_NOT_LINKED;
goto done;
}
-
}
static void gst_stream_selector_dispose (GObject * object);
@@ -497,6 +518,9 @@ gst_stream_selector_init (GstStreamSelector * sel)
sel->active_sinkpad = NULL;
sel->nb_sinkpads = 0;
gst_segment_init (&sel->segment, GST_FORMAT_UNDEFINED);
+
+ sel->blocked_cond = g_cond_new ();
+ sel->blocked = FALSE;
}
static void
@@ -509,6 +533,11 @@ gst_stream_selector_dispose (GObject * object)
sel->active_sinkpad = NULL;
}
+ if (sel->blocked_cond) {
+ g_cond_free (sel->blocked_cond);
+ sel->blocked_cond = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}