From f59b98569821fe974795fbf4e5662dde1858a8f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 6 Jan 2011 18:20:58 +0100 Subject: [PATCH] rtp: fix pad callbacks so they handle when parent goes away 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. --- gst-libs/gst/rtp/gstbasertpdepayload.c | 5 ++++- gst-libs/gst/rtp/gstbasertppayload.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/rtp/gstbasertpdepayload.c b/gst-libs/gst/rtp/gstbasertpdepayload.c index 58489b14d..94ca7edc9 100644 --- a/gst-libs/gst/rtp/gstbasertpdepayload.c +++ b/gst-libs/gst/rtp/gstbasertpdepayload.c @@ -481,12 +481,15 @@ gst_base_rtp_depayload_handle_sink_event (GstPad * pad, GstEvent * event) GstBaseRTPDepayload *filter; GstBaseRTPDepayloadClass *bclass; - filter = GST_BASE_RTP_DEPAYLOAD (GST_OBJECT_PARENT (pad)); + filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad)); + if (G_UNLIKELY (filter == NULL)) + return FALSE; bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter); if (bclass->handle_event) res = bclass->handle_event (filter, event); + gst_object_unref (filter); return res; } diff --git a/gst-libs/gst/rtp/gstbasertppayload.c b/gst-libs/gst/rtp/gstbasertppayload.c index a38918558..a04e30884 100644 --- a/gst-libs/gst/rtp/gstbasertppayload.c +++ b/gst-libs/gst/rtp/gstbasertppayload.c @@ -383,6 +383,8 @@ gst_basertppayload_event (GstPad * pad, GstEvent * event) gboolean res; basertppayload = GST_BASE_RTP_PAYLOAD (gst_pad_get_parent (pad)); + if (G_UNLIKELY (basertppayload == NULL)) + return FALSE; basertppayload_class = GST_BASE_RTP_PAYLOAD_GET_CLASS (basertppayload); if (basertppayload_class->handle_event) { -- 2.34.1