Commit fc5dc6de authored by Wim Taymans's avatar Wim Taymans

gst/gstbin.*: Work on proper clock selection.

Original commit message from CVS:
* gst/gstbin.c: (gst_bin_init), (gst_bin_provide_clock_func),
(gst_bin_add_func), (gst_bin_remove_func), (gst_bin_recalc_state),
(gst_bin_change_state_func), (bin_bus_handler):
* gst/gstbin.h:
Work on proper clock selection.
parent 8986d3f3
2005-10-11 Wim Taymans <wim@fluendo.com>
* gst/gstbin.c: (gst_bin_init), (gst_bin_provide_clock_func),
(gst_bin_add_func), (gst_bin_remove_func), (gst_bin_recalc_state),
(gst_bin_change_state_func), (bin_bus_handler):
* gst/gstbin.h:
Work on proper clock selection.
2005-10-11 Edward Hervey <edward@fluendo.com>
* libs/gst/controller/gstcontroller.c: (gst_controller_remove_properties_list):
......
common @ 615cf4d4
Subproject commit 54920e38c65eaf03ea52c21b14a6d104a56581a9
Subproject commit 615cf4d4506ef1ffb1f600c434fced1fa26b0f44
......@@ -289,6 +289,8 @@ gst_bin_init (GstBin * bin)
bin->eosed = NULL;
bin->polling = FALSE;
bin->state_dirty = FALSE;
bin->provided_clock = NULL;
bin->clock_dirty = FALSE;
/* Set up a bus for listening to child elements */
bus = g_object_new (gst_bus_get_type (), NULL);
......@@ -361,8 +363,11 @@ gst_bin_set_clock_func (GstElement * element, GstClock * clock)
* The ref of the returned clock in increased so unref after usage.
*
* MT safe
*
* FIXME, clock selection is not correct here.
*/
/*
* FIXME, clock selection is not correct here. We should loop the
* elements in state order and pick the last clock we can get. This
* makes sure we get a clock from the source.
*/
static GstClock *
gst_bin_provide_clock_func (GstElement * element)
......@@ -374,16 +379,32 @@ gst_bin_provide_clock_func (GstElement * element)
bin = GST_BIN (element);
GST_LOCK (bin);
if (!bin->clock_dirty)
goto not_dirty;
for (children = bin->children; children; children = g_list_next (children)) {
GstElement *child = GST_ELEMENT (children->data);
result = gst_element_provide_clock (child);
if (result)
if ((result = gst_element_provide_clock (child)))
break;
}
gst_object_replace ((GstObject **) & bin->provided_clock,
(GstObject *) result);
bin->clock_dirty = FALSE;
GST_DEBUG_OBJECT (bin, "provided new clock %p", result);
GST_UNLOCK (bin);
return result;
not_dirty:
{
if ((result = bin->provided_clock))
gst_object_ref (result);
GST_DEBUG_OBJECT (bin, "returning old clock %p", result);
GST_UNLOCK (bin);
return result;
}
}
/* Check if the bin is EOS. We do this by scanning all sinks and
......@@ -468,6 +489,11 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
elem_name);
GST_FLAG_SET (bin, GST_ELEMENT_IS_SINK);
}
if (gst_element_provides_clock (element)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin,
"element \"%s\" can provide a clock", elem_name);
bin->clock_dirty = TRUE;
}
bin->children = g_list_prepend (bin->children, element);
bin->numchildren++;
......@@ -618,6 +644,11 @@ gst_bin_remove_func (GstBin * bin, GstElement * element)
GST_FLAG_UNSET (bin, GST_ELEMENT_IS_SINK);
}
}
if (gst_element_provides_clock (element)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin,
"element \"%s\" could provide a clock", elem_name);
bin->clock_dirty = TRUE;
}
bin->state_dirty = TRUE;
GST_UNLOCK (bin);
......
......@@ -95,6 +95,9 @@ struct _GstBin {
gboolean polling;
gboolean state_dirty;
gboolean clock_dirty;
GstClock *provided_clock;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment