From d092e3b9fff5224029b3432ded0f337e27cf2bdc Mon Sep 17 00:00:00 2001 From: Havard Graff Date: Sun, 20 Mar 2011 00:56:08 +0100 Subject: [PATCH] queue[2]: Make src query MT-safe It is possible that the element might be going down while the event arrives --- plugins/elements/gstqueue.c | 14 +++++++++++--- plugins/elements/gstqueue2.c | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index e9e79f4..2594f04 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -1304,17 +1304,24 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event) static gboolean gst_queue_handle_src_query (GstPad * pad, GstQuery * query) { - GstQueue *queue = GST_QUEUE (GST_PAD_PARENT (pad)); + GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad)); GstPad *peer; gboolean res; - if (!(peer = gst_pad_get_peer (queue->sinkpad))) + if (G_UNLIKELY (queue == NULL)) return FALSE; + if (!(peer = gst_pad_get_peer (queue->sinkpad))) { + gst_object_unref (queue); + return FALSE; + } + res = gst_pad_query (peer, query); gst_object_unref (peer); - if (!res) + if (!res) { + gst_object_unref (queue); return FALSE; + } switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: @@ -1370,6 +1377,7 @@ gst_queue_handle_src_query (GstPad * pad, GstQuery * query) break; } + gst_object_unref (queue); return TRUE; } diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 0a2b28c..431c131 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -2441,7 +2441,9 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query) { GstQueue2 *queue; - queue = GST_QUEUE2 (GST_PAD_PARENT (pad)); + queue = GST_QUEUE2 (gst_pad_get_parent (pad)); + if (G_UNLIKELY (queue == NULL)) + return FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: @@ -2612,12 +2614,14 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query) break; } + gst_object_unref (queue); return TRUE; /* ERRORS */ peer_failed: { GST_DEBUG_OBJECT (queue, "failed peer query"); + gst_object_unref (queue); return FALSE; } } -- 2.7.4