From 01085fa26a160e1fccb692b9ffcffcd7eb77c6db Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 27 Sep 2005 09:57:20 +0000 Subject: [PATCH] gst/gstbin.c: use gst_object_has_ancestor(). Original commit message from CVS: * gst/gstbin.c: (bin_element_is_semi_sink), (gst_bin_change_state): use gst_object_has_ancestor(). * gst/gstobject.c: (gst_object_has_ancestor): * gst/gstobject.h: gst_object_has_ancestor() copied from gstbin.c as it is a usefull function. * tests/instantiate/create.c: (create_all_elements): * tests/lat.c: (handoff_src), (handoff_sink): * tests/sched/runxml.c: (main): * tests/seeking/seeking1.c: (main): * tests/threadstate/threadstate2.c: (bus_handler), (timeout_func), (main): Fix compilation of some tests. --- ChangeLog | 18 ++++++++++++++++++ gst/gstbin.c | 26 ++------------------------ gst/gstobject.c | 32 ++++++++++++++++++++++++++++++++ gst/gstobject.h | 1 + tests/instantiate/create.c | 6 +++++- tests/lat.c | 4 ++-- tests/sched/runxml.c | 2 +- tests/seeking/seeking1.c | 12 +++++++----- tests/threadstate/threadstate2.c | 2 +- 9 files changed, 69 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index d970eac..308ab73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2005-09-27 Wim Taymans + + * gst/gstbin.c: (bin_element_is_semi_sink), (gst_bin_change_state): + use gst_object_has_ancestor(). + + * gst/gstobject.c: (gst_object_has_ancestor): + * gst/gstobject.h: + gst_object_has_ancestor() copied from gstbin.c as it is a + usefull function. + + * tests/instantiate/create.c: (create_all_elements): + * tests/lat.c: (handoff_src), (handoff_sink): + * tests/sched/runxml.c: (main): + * tests/seeking/seeking1.c: (main): + * tests/threadstate/threadstate2.c: (bus_handler), (timeout_func), + (main): + Fix compilation of some tests. + 2005-09-27 Tim-Philipp Müller * gst/gsterror.h: diff --git a/gst/gstbin.c b/gst/gstbin.c index 3d2ceff..c57d5ec 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -824,29 +824,6 @@ bin_element_is_sink (GstElement * child, GstBin * bin) return is_sink ? 0 : 1; } -/* check if object has the given ancestor somewhere up in - * the hierarchy - */ -static gboolean -has_ancestor (GstObject * object, GstObject * ancestor) -{ - GstObject *parent; - gboolean result = FALSE; - - if (object == NULL) - return FALSE; - - if (object == ancestor) - return TRUE; - - parent = gst_object_get_parent (object); - result = has_ancestor (parent, ancestor); - if (parent) - gst_object_unref (parent); - - return result; -} - /* returns 0 when TRUE because this is a GCompareFunc. * This function returns elements that have no connected srcpads and * are therefore not reachable from a real sink. */ @@ -879,7 +856,8 @@ bin_element_is_semi_sink (GstElement * child, GstBin * bin) GST_DEBUG ("looking at pad %p", pads->data); if ((peer = gst_pad_get_peer (GST_PAD_CAST (pads->data)))) { connected_src = - has_ancestor (GST_OBJECT_CAST (peer), GST_OBJECT_CAST (bin)); + gst_object_has_ancestor (GST_OBJECT_CAST (peer), + GST_OBJECT_CAST (bin)); gst_object_unref (peer); if (connected_src) { break; diff --git a/gst/gstobject.c b/gst/gstobject.c index 11f5086..851d114 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -954,6 +954,38 @@ gst_object_unparent (GstObject * object) } /** + * gst_object_has_ancestor: + * @object: GstObject to check + * @ancestor: GstObject to check as ancestor + * + * Check if @object has an ancestor @ancestor somewhere up in + * the hierarchy. + * + * Returns: TRUE if @ancestor is an ancestor of @object. + * + * MT safe. Grabs and releases the object's locks. + */ +gboolean +gst_object_has_ancestor (GstObject * object, GstObject * ancestor) +{ + GstObject *parent; + gboolean result = FALSE; + + if (object == NULL) + return FALSE; + + if (object == ancestor) + return TRUE; + + parent = gst_object_get_parent (object); + result = gst_object_has_ancestor (parent, ancestor); + if (parent) + gst_object_unref (parent); + + return result; +} + +/** * gst_object_check_uniqueness: * @list: a list of #GstObject to check through * @name: the name to search for diff --git a/gst/gstobject.h b/gst/gstobject.h index 28ffaff..1bf35d4 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -237,6 +237,7 @@ gchar* gst_object_get_name_prefix (GstObject *object); gboolean gst_object_set_parent (GstObject *object, GstObject *parent); GstObject* gst_object_get_parent (GstObject *object); void gst_object_unparent (GstObject *object); +gboolean gst_object_has_ancestor (GstObject *object, GstObject *ancestor); void gst_object_default_deep_notify (GObject *object, GstObject *orig, GParamSpec *pspec, gchar **excluded_props); diff --git a/tests/instantiate/create.c b/tests/instantiate/create.c index ddbb5e5..2045a7d 100644 --- a/tests/instantiate/create.c +++ b/tests/instantiate/create.c @@ -31,9 +31,13 @@ create_all_elements (void) const GList *elements; GstElementFactory *factory; GstElement *element; + GstRegistry *registry; + + registry = gst_registry_get_default (); /* get list of elements */ - for (elements = gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY); + for (elements = + gst_registry_get_feature_list (registry, GST_TYPE_ELEMENT_FACTORY); elements != NULL; elements = elements->next) { factory = (GstElementFactory *) elements->data; if ((element = gst_element_factory_create (factory, "test"))) { diff --git a/tests/lat.c b/tests/lat.c index 197d74a..c4b3f89 100644 --- a/tests/lat.c +++ b/tests/lat.c @@ -13,7 +13,7 @@ static guint mhz = 0; void handoff_src (GstElement * src, GstBuffer * buf, gpointer user_data) { - gst_trace_read_tsc (&GST_BUFFER_TIMESTAMP (buf)); + gst_trace_read_tsc ((gint64 *) & GST_BUFFER_TIMESTAMP (buf)); } void @@ -22,7 +22,7 @@ handoff_sink (GstElement * sink, GstBuffer * buf, gpointer user_data) guint64 end, d, avg; guint avg_ns; - gst_trace_read_tsc (&end); + gst_trace_read_tsc ((gint64 *) & end); d = end - GST_BUFFER_TIMESTAMP (buf); if (d > max) max = d; diff --git a/tests/sched/runxml.c b/tests/sched/runxml.c index db2094e..e20bfd0 100644 --- a/tests/sched/runxml.c +++ b/tests/sched/runxml.c @@ -44,7 +44,7 @@ main (int argc, char *argv[]) g_print ("\n *** using testfile %s\n", argv[1]); xml = gst_xml_new (); - gst_xml_parse_file (xml, argv[1], NULL); + gst_xml_parse_file (xml, (const guchar *) argv[1], NULL); toplevelelements = gst_xml_get_topelements (xml); diff --git a/tests/seeking/seeking1.c b/tests/seeking/seeking1.c index d128080..b812d50 100644 --- a/tests/seeking/seeking1.c +++ b/tests/seeking/seeking1.c @@ -53,8 +53,9 @@ main (gint argc, gchar * argv[]) g_print ("doing segment seek from 5 to 10\n"); gst_pad_send_event (pad, - gst_event_new_segment_seek (GST_FORMAT_DEFAULT | - GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5, 10)); + gst_event_new_seek (1.0, GST_FORMAT_DEFAULT, + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT, + GST_SEEK_TYPE_SET, 5, GST_SEEK_TYPE_SET, 10)); format = GST_FORMAT_DEFAULT; @@ -77,9 +78,10 @@ main (gint argc, gchar * argv[]) ("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n"); looping = 3; - event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55); + event = + gst_event_new_seek (1.0, GST_FORMAT_DEFAULT, + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT, + GST_SEEK_TYPE_SET, 50, GST_SEEK_TYPE_SET, 55); gst_pad_send_event (pad, event); g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")), diff --git a/tests/threadstate/threadstate2.c b/tests/threadstate/threadstate2.c index 862fc45..3843d19 100644 --- a/tests/threadstate/threadstate2.c +++ b/tests/threadstate/threadstate2.c @@ -72,7 +72,7 @@ main (int argc, char *argv[]) g_timeout_add (2 * 1000, (GSourceFunc) timeout_func, loop); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_add_watch (bus, (GstBusHandler) bus_handler, pipeline); + gst_bus_add_watch (bus, GST_MESSAGE_ANY, (GstBusFunc) bus_handler, pipeline); for (x = 0; x < 10; x++) { g_print ("playing %d\n", x); -- 2.7.4