element: use flags for require/provide clock

Remove the _require/_provide_clock() methods and use element flags to mark
elements instead of looking at the implementation of the vmethod.
This commit is contained in:
Wim Taymans 2011-11-28 17:22:44 +01:00
parent d65773b5fa
commit 40616aeb63
4 changed files with 19 additions and 59 deletions

View file

@ -1045,7 +1045,7 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
{
gchar *elem_name;
GstIterator *it;
gboolean is_sink, is_source;
gboolean is_sink, is_source, provides_clock;
GstMessage *clock_message = NULL, *async_message = NULL;
GstStateChangeReturn ret;
@ -1060,6 +1060,8 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
elem_name = g_strdup (GST_ELEMENT_NAME (element));
is_sink = GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_SINK);
is_source = GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_SOURCE);
provides_clock =
GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
GST_OBJECT_UNLOCK (element);
GST_OBJECT_LOCK (bin);
@ -1087,7 +1089,7 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
elem_name);
GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_SOURCE);
}
if (gst_element_provides_clock (element)) {
if (provides_clock) {
GST_DEBUG_OBJECT (bin, "element \"%s\" can provide a clock", elem_name);
clock_message =
gst_message_new_clock_provide (GST_OBJECT_CAST (element), NULL, TRUE);

View file

@ -326,54 +326,6 @@ gst_element_release_request_pad (GstElement * element, GstPad * pad)
gst_element_remove_pad (element, pad);
}
/**
* gst_element_requires_clock:
* @element: a #GstElement to query
*
* Query if the element requires a clock.
*
* Returns: %TRUE if the element requires a clock
*
* MT safe.
*/
gboolean
gst_element_requires_clock (GstElement * element)
{
gboolean result;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
result = (GST_ELEMENT_GET_CLASS (element)->set_clock != NULL);
return result;
}
/**
* gst_element_provides_clock:
* @element: a #GstElement to query
*
* Query if the element provides a clock. A #GstClock provided by an
* element can be used as the global #GstClock for the pipeline.
* An element that can provide a clock is only required to do so in the PAUSED
* state, this means when it is fully negotiated and has allocated the resources
* to operate the clock.
*
* Returns: %TRUE if the element provides a clock
*
* MT safe.
*/
gboolean
gst_element_provides_clock (GstElement * element)
{
gboolean result;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
result = (GST_ELEMENT_GET_CLASS (element)->provide_clock != NULL);
return result;
}
/**
* gst_element_provide_clock:
* @element: a #GstElement to query

View file

@ -330,6 +330,8 @@ typedef enum
GST_ELEMENT_FLAG_LOCKED_STATE = (GST_OBJECT_FLAG_LAST << 1),
GST_ELEMENT_FLAG_SINK = (GST_OBJECT_FLAG_LAST << 2),
GST_ELEMENT_FLAG_SOURCE = (GST_OBJECT_FLAG_LAST << 3),
GST_ELEMENT_FLAG_PROVIDE_CLOCK = (GST_OBJECT_FLAG_LAST << 4),
GST_ELEMENT_FLAG_REQUIRE_CLOCK = (GST_OBJECT_FLAG_LAST << 5),
/* padding */
GST_ELEMENT_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
} GstElementFlags;
@ -725,8 +727,6 @@ GType gst_element_get_type (void);
#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT_CAST(elem),parent)
/* clocking */
gboolean gst_element_requires_clock (GstElement *element);
gboolean gst_element_provides_clock (GstElement *element);
GstClock* gst_element_provide_clock (GstElement *element);
GstClock* gst_element_get_clock (GstElement *element);
gboolean gst_element_set_clock (GstElement *element, GstClock *clock);

View file

@ -662,9 +662,14 @@ print_implementation_info (GstElement * element)
static void
print_clocking_info (GstElement * element)
{
if (!gst_element_requires_clock (element) &&
!(gst_element_provides_clock (element) &&
gst_element_get_clock (element))) {
gboolean requires_clock, provides_clock;
requires_clock =
GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
provides_clock =
GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
if (!requires_clock && !provides_clock) {
n_print ("\n");
n_print ("Element has no clocking capabilities.");
return;
@ -672,17 +677,18 @@ print_clocking_info (GstElement * element)
n_print ("\n");
n_print ("Clocking Interaction:\n");
if (gst_element_requires_clock (element)) {
if (requires_clock) {
n_print (" element requires a clock\n");
}
if (gst_element_provides_clock (element)) {
if (provides_clock) {
GstClock *clock;
clock = gst_element_get_clock (element);
if (clock)
if (clock) {
n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
else
gst_object_unref (clock);
} else
n_print (" element is supposed to provide a clock but returned NULL\n");
}
}