From: Stefan Kost Date: Tue, 23 Aug 2005 21:32:31 +0000 (+0000) Subject: gracefully handle helper method calls to objects that are not beeing controlled,... X-Git-Tag: RELEASE-0_9_2~94 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da9c04e2f0fa37d007c94e81b5226292178367b6;p=platform%2Fupstream%2Fgstreamer.git gracefully handle helper method calls to objects that are not beeing controlled, added test case for that Original commit message from CVS: * check/gst-libs/controller.c: (GST_START_TEST), (gst_controller_suite): * docs/gst/tmpl/gstcaps.sgml: * docs/gst/tmpl/gstghostpad.sgml: * docs/gst/tmpl/gstquery.sgml: * docs/gst/tmpl/gstutils.sgml: * libs/gst/controller/gst-helper.c: (gst_object_set_controller), (gst_object_sink_values), (gst_object_get_value_arrays), (gst_object_get_value_array): gracefully handle helper method calls to objects that are not beeing controlled, added test case for that --- diff --git a/ChangeLog b/ChangeLog index 8899fd0..bc4a2c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-08-24 Stefan Kost + + * check/gst-libs/controller.c: (GST_START_TEST), + (gst_controller_suite): + * docs/gst/tmpl/gstcaps.sgml: + * docs/gst/tmpl/gstghostpad.sgml: + * docs/gst/tmpl/gstquery.sgml: + * docs/gst/tmpl/gstutils.sgml: + * libs/gst/controller/gst-helper.c: (gst_object_set_controller), + (gst_object_sink_values), (gst_object_get_value_arrays), + (gst_object_get_value_array): + gracefully handle helper method calls to objects that are not beeing + controlled, added test case for that + 2005-08-23 Wim Taymans * gst/gstevent.c: (_gst_event_copy), (gst_event_new_custom), diff --git a/check/gst-libs/controller.c b/check/gst-libs/controller.c index 23d0a00..dfe9510 100644 --- a/check/gst-libs/controller.c +++ b/check/gst-libs/controller.c @@ -330,8 +330,24 @@ GST_START_TEST (controller_interpolate_none) GST_END_TEST; -/* @TODO write more tests (using an internal element that has controlable params) - */ +/* tests if we can run helper methods against any GObject */ +GST_START_TEST (controller_helper_any_gobject) +{ + GstElement *elem; + gboolean res; + + elem = gst_element_factory_make ("bin", "test_elem"); + + /* that element is not controllable */ + res = gst_object_sink_values (G_OBJECT (elem), 0LL); + fail_unless (res == FALSE, NULL); + + g_object_unref (elem); +} + +GST_END_TEST; + + Suite * gst_controller_suite (void) { @@ -346,6 +362,7 @@ gst_controller_suite (void) tcase_add_test (tc, controller_param_twice); tcase_add_test (tc, controller_finalize); tcase_add_test (tc, controller_interpolate_none); + tcase_add_test (tc, controller_helper_any_gobject); return s; } diff --git a/docs/gst/tmpl/gstcaps.sgml b/docs/gst/tmpl/gstcaps.sgml index fdc72d3..e2e3f7e 100644 --- a/docs/gst/tmpl/gstcaps.sgml +++ b/docs/gst/tmpl/gstcaps.sgml @@ -160,6 +160,16 @@ templates. @Returns: + + + + + +@caps: +@nth: +@Returns: + + diff --git a/docs/gst/tmpl/gstghostpad.sgml b/docs/gst/tmpl/gstghostpad.sgml index b92fdbd..46d8e03 100644 --- a/docs/gst/tmpl/gstghostpad.sgml +++ b/docs/gst/tmpl/gstghostpad.sgml @@ -35,3 +35,13 @@ Pseudo link pads @pad: + + + + + +@gpad: +@newtarget: +@Returns: + + diff --git a/docs/gst/tmpl/gstquery.sgml b/docs/gst/tmpl/gstquery.sgml index 3fcf8be..0eb813f 100644 --- a/docs/gst/tmpl/gstquery.sgml +++ b/docs/gst/tmpl/gstquery.sgml @@ -18,6 +18,15 @@ Query types can be used to perform queries on pads and elements. + + + + + +@mini_object: +@type: +@structure: + Standard predefined Query types diff --git a/docs/gst/tmpl/gstutils.sgml b/docs/gst/tmpl/gstutils.sgml index 754519f..08bde28 100644 --- a/docs/gst/tmpl/gstutils.sgml +++ b/docs/gst/tmpl/gstutils.sgml @@ -65,6 +65,50 @@ various utility functions @element: + + + + + +@bin: + + + + + + + +@type: +@type_as_function: +@parent_type: +@\ + parent_type_as_macro: +@\ + parent_type_as_macro: +@\ + parent_type_as_macro: +@\ + parent_type_as_macro: +@\ + parent_type_as_macro: +@\ + parent_type_as_macro: +@interface_type: +@interface_type_as_macro: +@\ + interface_as_function: +@\ + interface_as_function: +@\ + interface_as_function: +@\ + interface_as_function: +@\ + interface_as_function: +@\ + interface_as_function: + + diff --git a/libs/gst/controller/gst-helper.c b/libs/gst/controller/gst-helper.c index 3c7ee19..2fab80c 100644 --- a/libs/gst/controller/gst-helper.c +++ b/libs/gst/controller/gst-helper.c @@ -131,10 +131,11 @@ gst_object_set_controller (GObject * object, GstController * controller) g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (controller, FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (!ctrl, FALSE); - g_object_set_qdata (object, controller_key, controller); - return (TRUE); + if (!(ctrl = g_object_get_qdata (object, controller_key))) { + g_object_set_qdata (object, controller_key, controller); + return (TRUE); + } + return (FALSE); } /** @@ -155,9 +156,10 @@ gst_object_sink_values (GObject * object, GstClockTime timestamp) g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (ctrl, FALSE); - return gst_controller_sink_values (ctrl, timestamp); + if ((ctrl = g_object_get_qdata (object, controller_key))) { + return gst_controller_sink_values (ctrl, timestamp); + } + return (FALSE); } /** @@ -187,9 +189,10 @@ gst_object_get_value_arrays (GObject * object, GstClockTime timestamp, g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (ctrl, FALSE); - return gst_controller_get_value_arrays (ctrl, timestamp, value_arrays); + if ((ctrl = g_object_get_qdata (object, controller_key))) { + return gst_controller_get_value_arrays (ctrl, timestamp, value_arrays); + } + return (FALSE); } /** @@ -217,8 +220,8 @@ gst_object_get_value_array (GObject * object, GstClockTime timestamp, g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (ctrl, FALSE); - - return gst_controller_get_value_array (ctrl, timestamp, value_array); + if ((ctrl = g_object_get_qdata (object, controller_key))) { + return gst_controller_get_value_array (ctrl, timestamp, value_array); + } + return (FALSE); } diff --git a/libs/gst/controller/gsthelper.c b/libs/gst/controller/gsthelper.c index 3c7ee19..2fab80c 100644 --- a/libs/gst/controller/gsthelper.c +++ b/libs/gst/controller/gsthelper.c @@ -131,10 +131,11 @@ gst_object_set_controller (GObject * object, GstController * controller) g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (controller, FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (!ctrl, FALSE); - g_object_set_qdata (object, controller_key, controller); - return (TRUE); + if (!(ctrl = g_object_get_qdata (object, controller_key))) { + g_object_set_qdata (object, controller_key, controller); + return (TRUE); + } + return (FALSE); } /** @@ -155,9 +156,10 @@ gst_object_sink_values (GObject * object, GstClockTime timestamp) g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (ctrl, FALSE); - return gst_controller_sink_values (ctrl, timestamp); + if ((ctrl = g_object_get_qdata (object, controller_key))) { + return gst_controller_sink_values (ctrl, timestamp); + } + return (FALSE); } /** @@ -187,9 +189,10 @@ gst_object_get_value_arrays (GObject * object, GstClockTime timestamp, g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (ctrl, FALSE); - return gst_controller_get_value_arrays (ctrl, timestamp, value_arrays); + if ((ctrl = g_object_get_qdata (object, controller_key))) { + return gst_controller_get_value_arrays (ctrl, timestamp, value_arrays); + } + return (FALSE); } /** @@ -217,8 +220,8 @@ gst_object_get_value_array (GObject * object, GstClockTime timestamp, g_return_val_if_fail (G_IS_OBJECT (object), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - ctrl = g_object_get_qdata (object, controller_key); - g_return_val_if_fail (ctrl, FALSE); - - return gst_controller_get_value_array (ctrl, timestamp, value_array); + if ((ctrl = g_object_get_qdata (object, controller_key))) { + return gst_controller_get_value_array (ctrl, timestamp, value_array); + } + return (FALSE); } diff --git a/tests/check/libs/controller.c b/tests/check/libs/controller.c index 23d0a00..dfe9510 100644 --- a/tests/check/libs/controller.c +++ b/tests/check/libs/controller.c @@ -330,8 +330,24 @@ GST_START_TEST (controller_interpolate_none) GST_END_TEST; -/* @TODO write more tests (using an internal element that has controlable params) - */ +/* tests if we can run helper methods against any GObject */ +GST_START_TEST (controller_helper_any_gobject) +{ + GstElement *elem; + gboolean res; + + elem = gst_element_factory_make ("bin", "test_elem"); + + /* that element is not controllable */ + res = gst_object_sink_values (G_OBJECT (elem), 0LL); + fail_unless (res == FALSE, NULL); + + g_object_unref (elem); +} + +GST_END_TEST; + + Suite * gst_controller_suite (void) { @@ -346,6 +362,7 @@ gst_controller_suite (void) tcase_add_test (tc, controller_param_twice); tcase_add_test (tc, controller_finalize); tcase_add_test (tc, controller_interpolate_none); + tcase_add_test (tc, controller_helper_any_gobject); return s; }