decodebin: use iterators instead of list

The list api is deprecated. Use threadsafe iterators instead.
This commit is contained in:
Stefan Kost 2009-04-29 18:36:17 +03:00
parent 7d049bc29f
commit eeb3300383

View file

@ -1286,7 +1286,9 @@ get_our_ghost_pad (GstDecodeBin * decode_bin, GstPad * pad)
static void static void
remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad) remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
{ {
GList *int_links, *walk; GstIterator *iter;
gboolean done = FALSE;
gpointer item;
GstElement *elem = GST_ELEMENT (GST_OBJECT_PARENT (pad)); GstElement *elem = GST_ELEMENT (GST_OBJECT_PARENT (pad));
while (GST_OBJECT_PARENT (elem) && while (GST_OBJECT_PARENT (elem) &&
@ -1300,16 +1302,20 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
} }
GST_DEBUG_OBJECT (decode_bin, "%s:%s", GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_OBJECT (decode_bin, "%s:%s", GST_DEBUG_PAD_NAME (pad));
int_links = gst_pad_get_internal_links (pad); iter = gst_pad_iterate_internal_links (pad);
if (!iter)
goto no_iter;
/* remove all elements linked to this pad up to the ghostpad /* remove all elements linked to this pad up to the ghostpad
* that we created for this stream */ * that we created for this stream */
for (walk = int_links; walk; walk = g_list_next (walk)) { while (!done) {
switch (gst_iterator_next (iter, &item)) {
case GST_ITERATOR_OK:{
GstPad *pad; GstPad *pad;
GstPad *ghostpad; GstPad *ghostpad;
GstPad *peer; GstPad *peer;
pad = GST_PAD (walk->data); pad = GST_PAD (item);
GST_DEBUG_OBJECT (decode_bin, "inspecting internal pad %s:%s", GST_DEBUG_OBJECT (decode_bin, "inspecting internal pad %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
@ -1329,15 +1335,13 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
} }
peer = gst_pad_get_peer (pad); peer = gst_pad_get_peer (pad);
if (peer == NULL) if (peer) {
continue;
GST_DEBUG_OBJECT (decode_bin, "internal pad %s:%s linked to pad %s:%s",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer));
{
GstObject *parent = gst_pad_get_parent (peer); GstObject *parent = gst_pad_get_parent (peer);
GST_DEBUG_OBJECT (decode_bin,
"internal pad %s:%s linked to pad %s:%s",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer));
if (parent) { if (parent) {
GstObject *grandparent = gst_object_get_parent (parent); GstObject *grandparent = gst_object_get_parent (parent);
@ -1346,7 +1350,8 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
GST_DEBUG_OBJECT (decode_bin, "dead end pad %s:%s parent %s", GST_DEBUG_OBJECT (decode_bin, "dead end pad %s:%s parent %s",
GST_DEBUG_PAD_NAME (peer), GST_OBJECT_NAME (grandparent)); GST_DEBUG_PAD_NAME (peer), GST_OBJECT_NAME (grandparent));
} else { } else {
GST_DEBUG_OBJECT (decode_bin, "recursing element %s on pad %s:%s", GST_DEBUG_OBJECT (decode_bin,
"recursing element %s on pad %s:%s",
GST_ELEMENT_NAME (elem), GST_DEBUG_PAD_NAME (pad)); GST_ELEMENT_NAME (elem), GST_DEBUG_PAD_NAME (pad));
remove_element_chain (decode_bin, peer); remove_element_chain (decode_bin, peer);
} }
@ -1354,15 +1359,29 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
} }
gst_object_unref (parent); gst_object_unref (parent);
} }
}
gst_object_unref (peer); gst_object_unref (peer);
} }
gst_object_unref (item);
}
break;
case GST_ITERATOR_RESYNC:
gst_iterator_resync (iter);
break;
case GST_ITERATOR_ERROR:
GST_ERROR_OBJECT (pad, "Could not iterate over internally linked pads");
done = TRUE;
break;
case GST_ITERATOR_DONE:
done = TRUE;
break;
}
}
GST_DEBUG_OBJECT (decode_bin, "removing %s", GST_ELEMENT_NAME (elem)); GST_DEBUG_OBJECT (decode_bin, "removing %s", GST_ELEMENT_NAME (elem));
g_list_free (int_links); gst_iterator_free (iter);
no_iter:
gst_element_set_state (elem, GST_STATE_NULL); gst_element_set_state (elem, GST_STATE_NULL);
gst_bin_remove (GST_BIN (decode_bin), elem); gst_bin_remove (GST_BIN (decode_bin), elem);
} }