summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e7bf548)
raw | patch | inline | side by side (parent: e7bf548)
author | Ole André Vadla Ravnås <oravnas@cisco.com> | |
Thu, 6 Jan 2011 17:11:31 +0000 (18:11 +0100) | ||
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | |
Wed, 13 Apr 2011 15:41:17 +0000 (17:41 +0200) |
1) We need to lock and get a strong ref to the parent, if still there.
2) If it has gone away, we need to handle that gracefully.
This is necessary in order to safely modify a running pipeline. Has been
observed when a streaming thread is doing a buffer_alloc() while an
application thread sends an event on a pad further downstream, and from
within a pad probe (holding STREAM_LOCK) carries out the pipeline plumbing
while the streaming thread has its buffer_alloc() in progress.
2) If it has gone away, we need to handle that gracefully.
This is necessary in order to safely modify a running pipeline. Has been
observed when a streaming thread is doing a buffer_alloc() while an
application thread sends an event on a pad further downstream, and from
within a pad probe (holding STREAM_LOCK) carries out the pipeline plumbing
while the streaming thread has its buffer_alloc() in progress.
index 615e412f0fe48c7d2c65a5e0bcd4b52ebdede1fd..bf5e8c1896c87756dc19c87145f326d076e4da94 100644 (file)
GstCaps * caps, GstBuffer ** buf)
{
GstFunnel *funnel = GST_FUNNEL (gst_pad_get_parent_element (pad));
- GstFlowReturn ret = GST_FLOW_OK;
+ GstFlowReturn ret;
+
+ if (G_UNLIKELY (funnel == NULL))
+ return GST_FLOW_WRONG_STATE;
ret = gst_pad_alloc_buffer (funnel->srcpad, offset, size, caps, buf);
GstFunnel *funnel = GST_FUNNEL (gst_pad_get_parent (pad));
GstCaps *caps;
+ if (G_UNLIKELY (funnel == NULL))
+ return gst_caps_new_any ();
+
caps = gst_pad_peer_get_caps_reffed (funnel->srcpad);
if (caps == NULL)
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
gboolean forward = TRUE;
gboolean res = TRUE;
+ if (G_UNLIKELY (funnel == NULL)) {
+ gst_event_unref (event);
+ return FALSE;
+ }
+
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
{
GST_OBJECT_UNLOCK (funnel);
forward = FALSE;
- gst_event_unref (event);
}
break;
case GST_EVENT_FLUSH_STOP:
if (forward)
res = gst_pad_push_event (funnel->srcpad, event);
+ else
+ gst_event_unref (event);
gst_object_unref (funnel);
gboolean done = FALSE;
funnel = gst_pad_get_parent_element (pad);
- g_return_val_if_fail (funnel != NULL, FALSE);
+ if (G_UNLIKELY (funnel == NULL)) {
+ gst_event_unref (event);
+ return FALSE;
+ }
iter = gst_element_iterate_sink_pads (funnel);
index 9d136957d7fbc05d2380fb4681889ee0b713ebfd..32a4aa9a060f6e1dd7abd5d0f112936a0917a842 100644 (file)
GstPad *active_sinkpad;
sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (sel == NULL)) {
+ gst_event_unref (event);
+ return FALSE;
+ }
selpad = GST_SELECTOR_PAD_CAST (pad);
GST_INPUT_SELECTOR_LOCK (sel);
GstCaps *caps;
sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (sel == NULL))
+ return gst_caps_new_any ();
GST_DEBUG_OBJECT (sel, "Getting caps of srcpad peer");
caps = gst_pad_peer_get_caps_reffed (sel->srcpad);
gboolean res;
sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (sel == NULL))
+ return FALSE;
GST_DEBUG_OBJECT (sel, "Checking acceptcaps of srcpad peer");
res = gst_pad_peer_accept_caps (sel->srcpad, caps);
GstSelectorPad *selpad;
sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (sel == NULL))
+ return GST_FLOW_WRONG_STATE;
+
selpad = GST_SELECTOR_PAD_CAST (pad);
GST_LOG_OBJECT (pad, "received alloc");
index 9a4db2ac4202e3f780b0fac8a9b3acfec295ada3..f3ce6e295d7f283c2eae3cc272beb1a2d897c451 100644 (file)
static GstCaps *
gst_output_selector_sink_getcaps (GstPad * pad)
{
- GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad));
+ GstOutputSelector *sel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
GstPad *active = NULL;
GstCaps *caps = NULL;
+ if (G_UNLIKELY (sel == NULL))
+ return gst_caps_new_any ();
+
GST_OBJECT_LOCK (sel);
if (sel->pending_srcpad)
active = gst_object_ref (sel->pending_srcpad);
if (caps == NULL) {
caps = gst_caps_new_any ();
}
+
+ gst_object_unref (sel);
return caps;
}
GstFlowReturn res;
GstPad *allocpad;
- sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad));
+ sel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (sel == NULL))
+ return GST_FLOW_WRONG_STATE;
res = GST_FLOW_NOT_LINKED;
GST_OBJECT_LOCK (sel);
GST_DEBUG_OBJECT (sel, "buffer alloc finished: %s", gst_flow_get_name (res));
+ gst_object_unref (sel);
return res;
}
GstPad *output_pad = NULL;
sel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (sel == NULL)) {
+ gst_event_unref (event);
+ return FALSE;
+ }
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
index 2594f048727f3a2277d77b7053a41f85afaa7d44..ceca353f640b91fea8f85fe51e75cebfd8c53271 100644 (file)
GstQueue *queue;
GstPad *otherpad;
- queue = GST_QUEUE (GST_PAD_PARENT (pad));
+ queue = GST_QUEUE (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (queue == NULL))
+ return FALSE;
otherpad = (pad == queue->srcpad ? queue->sinkpad : queue->srcpad);
result = gst_pad_peer_accept_caps (otherpad, caps);
+ gst_object_unref (queue);
+
return result;
}
@@ -545,11 +549,14 @@ gst_queue_bufferalloc (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
GstQueue *queue;
GstFlowReturn result;
- queue = GST_QUEUE (GST_PAD_PARENT (pad));
+ queue = GST_QUEUE (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (queue == NULL))
+ return GST_FLOW_WRONG_STATE;
/* Forward to src pad, without setting caps on the src pad */
result = gst_pad_alloc_buffer (queue->srcpad, offset, size, caps, buf);
+ gst_object_unref (queue);
return result;
}
{
GstQueue *queue;
- queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
+ queue = GST_QUEUE (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (queue == NULL)) {
+ gst_event_unref (event);
+ return FALSE;
+ }
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
break;
}
done:
+ gst_object_unref (queue);
return TRUE;
/* ERRORS */
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
"refusing event, we are flushing");
GST_QUEUE_MUTEX_UNLOCK (queue);
+ gst_object_unref (queue);
gst_event_unref (event);
return FALSE;
}
{
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "refusing event, we are EOS");
GST_QUEUE_MUTEX_UNLOCK (queue);
+ gst_object_unref (queue);
gst_event_unref (event);
return FALSE;
}
index 54700774e1391a60fbf6221fc12a86f35766149c..bf9fef2be57906505a2969b9d8f87e5280496b97 100644 (file)
GstFlowReturn res;
GstPad *allocpad;
- tee = GST_TEE_CAST (GST_PAD_PARENT (pad));
+ tee = GST_TEE_CAST (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (tee == NULL))
+ return GST_FLOW_WRONG_STATE;
res = GST_FLOW_NOT_LINKED;
}
GST_OBJECT_UNLOCK (tee);
+ gst_object_unref (tee);
return res;
}