From 8ee3931e5da21cef80b29f311ee89205f286751e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 25 Sep 2009 11:07:02 +0200 Subject: [PATCH] inputselector: Use new single iterator for the internally linked pads This fixes a deadlock and removes some useless code. --- plugins/elements/gstinputselector.c | 63 ++++--------------------------------- 1 file changed, 6 insertions(+), 57 deletions(-) diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c index 3fdba0b..329b130 100644 --- a/plugins/elements/gstinputselector.c +++ b/plugins/elements/gstinputselector.c @@ -320,71 +320,20 @@ gst_selector_pad_reset (GstSelectorPad * pad) /* strictly get the linked pad from the sinkpad. If the pad is active we return * the srcpad else we return NULL */ -typedef struct -{ - GstIterator parent; - - GstPad *pad; - gboolean start; -} GstSelectorIterator; - -static void -_iterate_free (GstIterator * it) -{ - GstSelectorIterator *sit = (GstSelectorIterator *) it; - - gst_object_unref (sit->pad); - g_free (it); -} - -static GstIteratorResult -_iterate_next (GstIterator * it, gpointer * result) -{ - GstSelectorIterator *sit = (GstSelectorIterator *) it; - - if (sit->start) { - GstPad *res = gst_input_selector_get_linked_pad (sit->pad, TRUE); - - *result = res; - sit->start = FALSE; - return GST_ITERATOR_OK; - } - - *result = NULL; - return GST_ITERATOR_DONE; -} - -static GstIteratorItem -_iterate_item (GstIterator * it, gpointer item) -{ - return GST_ITERATOR_ITEM_PASS; -} - -static void -_iterate_resync (GstIterator * it) -{ - GstSelectorIterator *sit = (GstSelectorIterator *) it; - - sit->start = TRUE; -} static GstIterator * gst_selector_pad_iterate_linked_pads (GstPad * pad) { GstInputSelector *sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad)); - GstSelectorIterator *it = (GstSelectorIterator *) - gst_iterator_new (sizeof (GstSelectorIterator), - GST_TYPE_PAD, - sel->lock, - &GST_ELEMENT_CAST (sel)->pads_cookie, - _iterate_next, _iterate_item, _iterate_resync, _iterate_free); - - it->pad = gst_object_ref (pad); - it->start = TRUE; + GstPad *opad = gst_input_selector_get_linked_pad (pad, TRUE); + GstIterator *it = gst_iterator_new_single (GST_TYPE_PAD, opad, + (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref); + if (opad) + gst_object_unref (opad); gst_object_unref (sel); - return (GstIterator *) it; + return it; } static gboolean -- 2.7.4