multiqueue: Simplify gst_multi_queue_iterate_internal_links

We don't need to obtain the mutex to ensure that `sq` is non-NULL. `sq`
is assigned immediately after the pads are created and not destroyed
until the pads are finalized.

Use the pad direction to determine which internal peer we need.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/888>
This commit is contained in:
Jan Alexander Steffens (heftig) 2021-05-06 14:07:35 +02:00 committed by GStreamer Marge Bot
parent 53c145a158
commit cd827e790a

View file

@ -1147,42 +1147,31 @@ gst_multi_queue_get_property (GObject * object, guint prop_id,
static GstIterator * static GstIterator *
gst_multi_queue_iterate_internal_links (GstPad * pad, GstObject * parent) gst_multi_queue_iterate_internal_links (GstPad * pad, GstObject * parent)
{ {
GstSingleQueue *sq = GST_MULTIQUEUE_PAD (pad)->sq;
GstIterator *it = NULL; GstIterator *it = NULL;
GstPad *opad, *sinkpad, *srcpad; GstPad *opad;
GstSingleQueue *squeue;
GstMultiQueue *mq = GST_MULTI_QUEUE (parent);
GValue val = { 0, };
GST_MULTI_QUEUE_MUTEX_LOCK (mq); switch (GST_PAD_DIRECTION (pad)) {
squeue = GST_MULTIQUEUE_PAD (pad)->sq; case GST_PAD_SRC:
if (!squeue) opad = g_weak_ref_get (&sq->sinkpad);
goto out; break;
srcpad = g_weak_ref_get (&squeue->srcpad); case GST_PAD_SINK:
sinkpad = g_weak_ref_get (&squeue->sinkpad); opad = g_weak_ref_get (&sq->srcpad);
if (sinkpad == pad && srcpad) { break;
opad = srcpad;
gst_clear_object (&sinkpad);
} else if (srcpad == pad && sinkpad) { default:
opad = sinkpad; g_return_val_if_reached (NULL);
gst_clear_object (&srcpad);
} else {
gst_clear_object (&srcpad);
gst_clear_object (&sinkpad);
goto out;
} }
g_value_init (&val, GST_TYPE_PAD); if (opad) {
g_value_set_object (&val, opad); GValue val = G_VALUE_INIT;
it = gst_iterator_new_single (GST_TYPE_PAD, &val);
g_value_unset (&val);
gst_object_unref (opad); g_value_init (&val, GST_TYPE_PAD);
g_value_take_object (&val, opad);
out: it = gst_iterator_new_single (GST_TYPE_PAD, &val);
GST_MULTI_QUEUE_MUTEX_UNLOCK (mq); g_value_unset (&val);
}
return it; return it;
} }