gst/gstbin.c (gst_bin_iterate_sinks): Use sink_iterator_filter so as to get the refs right.

Original commit message from CVS:
2005-05-14  Andy Wingo  <wingo@pobox.com>

* gst/gstbin.c (gst_bin_iterate_sinks): Use sink_iterator_filter
so as to get the refs right.
(sink_iterator_filter): New function, wraps bin_element_is_sink,
unreffing objects that don't pass the filter.
This commit is contained in:
Andy Wingo 2005-05-14 18:01:12 +00:00
parent 4765634c62
commit ab5ba6271c
2 changed files with 24 additions and 14 deletions

View file

@ -1,5 +1,10 @@
2005-05-14 Andy Wingo <wingo@pobox.com>
* gst/gstbin.c (gst_bin_iterate_sinks): Use sink_iterator_filter
so as to get the refs right.
(sink_iterator_filter): New function, wraps bin_element_is_sink,
unreffing objects that don't pass the filter.
* gst/gstpipeline.c (gst_pipeline_init): Drop ref on bus after
gst_element_set_bus.
(gst_pipeline_dispose): Set the bus on the pipeline to NULL. In

View file

@ -685,16 +685,10 @@ gst_bin_iterate_recurse (GstBin * bin)
return result;
}
/* returns 0 if the element is a sink, this is made so that
* we can use this function as a filter
*
* MT safe
*/
/* MT safe */
static gint
bin_element_is_sink (GstElement * child, GstBin * bin)
{
gint ret;
/* we lock the child here for the remainder of the function to
* get its name safely. */
GST_LOCK (child);
@ -702,14 +696,28 @@ bin_element_is_sink (GstElement * child, GstBin * bin)
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
"finding child %s as sink", GST_OBJECT_NAME (child));
GST_UNLOCK (child);
ret = 0;
/* returns 0 because this is a GCompareFunc */
return 0;
} else {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
"child %s is not a sink", GST_OBJECT_NAME (child));
GST_UNLOCK (child);
ret = 1;
return 1;
}
}
static gint
sink_iterator_filter (GstElement * child, GstBin * bin)
{
if (bin_element_is_sink (child, bin)) {
/* returns 0 because this is a GCompareFunc */
return 0;
} else {
/* child carries a ref from gst_bin_iterate_elements -- drop if not passing
through */
gst_object_unref ((GstObject *) child);
return 1;
}
return ret;
}
/**
@ -736,7 +744,7 @@ gst_bin_iterate_sinks (GstBin * bin)
children = gst_bin_iterate_elements (bin);
result = gst_iterator_filter (children,
(GCompareFunc) bin_element_is_sink, bin);
(GCompareFunc) sink_iterator_filter, bin);
return result;
}
@ -877,9 +885,6 @@ restart:
GST_UNLOCK (bin);
if (bin_element_is_sink (child, bin) == 0) {
/* this also keeps the refcount on the element, note that
* the _is_sink function unrefs the element when it is not
* a sink. */
g_queue_push_tail (elem_queue, child);
} else {
g_queue_push_tail (temp, child);