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
This commit is contained in:
Stefan Kost 2005-08-23 21:32:31 +00:00
parent bc3dfd5d55
commit da9c04e2f0
9 changed files with 159 additions and 32 deletions

View file

@ -1,3 +1,17 @@
2005-08-24 Stefan Kost <ensonic@users.sf.net>
* 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 <wim@fluendo.com>
* gst/gstevent.c: (_gst_event_copy), (gst_event_new_custom),

View file

@ -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;
}

View file

@ -160,6 +160,16 @@ templates.
@Returns:
<!-- ##### FUNCTION gst_caps_copy_nth ##### -->
<para>
</para>
@caps:
@nth:
@Returns:
<!-- ##### FUNCTION gst_static_caps_get ##### -->
<para>

View file

@ -35,3 +35,13 @@ Pseudo link pads
@pad:
<!-- ##### FUNCTION gst_ghost_pad_set_target ##### -->
<para>
</para>
@gpad:
@newtarget:
@Returns:

View file

@ -18,6 +18,15 @@ Query types can be used to perform queries on pads and elements.
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstQuery ##### -->
<para>
</para>
@mini_object:
@type:
@structure:
<!-- ##### ENUM GstQueryType ##### -->
<para>
Standard predefined Query types

View file

@ -65,6 +65,50 @@ various utility functions
@element:
<!-- ##### FUNCTION gst_bin_watch_for_state_change ##### -->
<para>
</para>
@bin:
<!-- ##### MACRO GST_BOILERPLATE_WITH_INTERFACE ##### -->
<para>
</para>
@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:
<!-- ##### MACRO GST_BOILERPLATE_FULL ##### -->
<para>

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}