mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 12:32:29 +00:00
autoconvert: Remove broken usage of the iterator
We're a subclass, so we can just take the object lock and iterate the list directly.
This commit is contained in:
parent
907ffc7352
commit
f3f6cdd451
1 changed files with 11 additions and 35 deletions
|
@ -269,48 +269,24 @@ gst_auto_convert_get_property (GObject * object,
|
|||
static GstElement *
|
||||
gst_auto_convert_get_element_by_type (GstAutoConvert * autoconvert, GType type)
|
||||
{
|
||||
GstIterator *iter = NULL;
|
||||
gboolean done;
|
||||
GValue item = { 0, };
|
||||
GList *item;
|
||||
GstBin *bin = GST_BIN (autoconvert);
|
||||
GstElement *element = NULL;
|
||||
|
||||
g_return_val_if_fail (type != 0, NULL);
|
||||
|
||||
iter = gst_bin_iterate_elements (GST_BIN (autoconvert));
|
||||
GST_OBJECT_LOCK (autoconvert);
|
||||
|
||||
if (!iter)
|
||||
return NULL;
|
||||
|
||||
done = FALSE;
|
||||
while (!done) {
|
||||
switch (gst_iterator_next (iter, &item)) {
|
||||
case GST_ITERATOR_OK:
|
||||
if (G_TYPE_CHECK_VALUE_TYPE (&item, type))
|
||||
done = TRUE;
|
||||
else
|
||||
g_value_unset (&item);
|
||||
break;
|
||||
case GST_ITERATOR_RESYNC:
|
||||
gst_iterator_resync (iter);
|
||||
g_value_unset (&item);
|
||||
break;
|
||||
case GST_ITERATOR_ERROR:
|
||||
GST_ERROR ("Error iterating elements in bin");
|
||||
g_value_unset (&item);
|
||||
done = TRUE;
|
||||
break;
|
||||
case GST_ITERATOR_DONE:
|
||||
g_value_unset (&item);
|
||||
done = TRUE;
|
||||
for (item = bin->children; item; item = item->next) {
|
||||
if (G_TYPE_CHECK_INSTANCE_TYPE (item->data, type)) {
|
||||
element = gst_object_ref (item->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
gst_iterator_free (iter);
|
||||
|
||||
/* Don't need to dup, the value on the stack has a ref, we steal it */
|
||||
if (G_VALUE_HOLDS_OBJECT (&item))
|
||||
return g_value_get_object (&item);
|
||||
else
|
||||
return NULL;
|
||||
GST_OBJECT_UNLOCK (autoconvert);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue