mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
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:
parent
4765634c62
commit
ab5ba6271c
2 changed files with 24 additions and 14 deletions
|
@ -1,5 +1,10 @@
|
||||||
2005-05-14 Andy Wingo <wingo@pobox.com>
|
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/gstpipeline.c (gst_pipeline_init): Drop ref on bus after
|
||||||
gst_element_set_bus.
|
gst_element_set_bus.
|
||||||
(gst_pipeline_dispose): Set the bus on the pipeline to NULL. In
|
(gst_pipeline_dispose): Set the bus on the pipeline to NULL. In
|
||||||
|
|
33
gst/gstbin.c
33
gst/gstbin.c
|
@ -685,16 +685,10 @@ gst_bin_iterate_recurse (GstBin * bin)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns 0 if the element is a sink, this is made so that
|
/* MT safe */
|
||||||
* we can use this function as a filter
|
|
||||||
*
|
|
||||||
* MT safe
|
|
||||||
*/
|
|
||||||
static gint
|
static gint
|
||||||
bin_element_is_sink (GstElement * child, GstBin * bin)
|
bin_element_is_sink (GstElement * child, GstBin * bin)
|
||||||
{
|
{
|
||||||
gint ret;
|
|
||||||
|
|
||||||
/* we lock the child here for the remainder of the function to
|
/* we lock the child here for the remainder of the function to
|
||||||
* get its name safely. */
|
* get its name safely. */
|
||||||
GST_LOCK (child);
|
GST_LOCK (child);
|
||||||
|
@ -702,14 +696,28 @@ bin_element_is_sink (GstElement * child, GstBin * bin)
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
|
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
|
||||||
"finding child %s as sink", GST_OBJECT_NAME (child));
|
"finding child %s as sink", GST_OBJECT_NAME (child));
|
||||||
GST_UNLOCK (child);
|
GST_UNLOCK (child);
|
||||||
ret = 0;
|
/* returns 0 because this is a GCompareFunc */
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
|
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
|
||||||
"child %s is not a sink", GST_OBJECT_NAME (child));
|
"child %s is not a sink", GST_OBJECT_NAME (child));
|
||||||
GST_UNLOCK (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);
|
children = gst_bin_iterate_elements (bin);
|
||||||
result = gst_iterator_filter (children,
|
result = gst_iterator_filter (children,
|
||||||
(GCompareFunc) bin_element_is_sink, bin);
|
(GCompareFunc) sink_iterator_filter, bin);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -877,9 +885,6 @@ restart:
|
||||||
GST_UNLOCK (bin);
|
GST_UNLOCK (bin);
|
||||||
|
|
||||||
if (bin_element_is_sink (child, bin) == 0) {
|
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);
|
g_queue_push_tail (elem_queue, child);
|
||||||
} else {
|
} else {
|
||||||
g_queue_push_tail (temp, child);
|
g_queue_push_tail (temp, child);
|
||||||
|
|
Loading…
Reference in a new issue