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.
This commit is contained in:
Ole André Vadla Ravnås 2011-01-06 18:20:58 +01:00 committed by Sebastian Dröge
parent 8ff295a788
commit f59b985698
2 changed files with 6 additions and 1 deletions

View file

@ -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;
}

View file

@ -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) {