gracefully handle helper method calls to objects that are not beeing controlled,...
authorStefan Kost <ensonic@users.sourceforge.net>
Tue, 23 Aug 2005 21:32:31 +0000 (21:32 +0000)
committerStefan Kost <ensonic@users.sourceforge.net>
Tue, 23 Aug 2005 21:32:31 +0000 (21:32 +0000)
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

ChangeLog
check/gst-libs/controller.c
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
libs/gst/controller/gsthelper.c
tests/check/libs/controller.c

index 8899fd0..bc4a2c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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),
index 23d0a00..dfe9510 100644 (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;
 }
index fdc72d3..e2e3f7e 100644 (file)
@@ -160,6 +160,16 @@ templates.
 @Returns: 
 
 
+<!-- ##### FUNCTION gst_caps_copy_nth ##### -->
+<para>
+
+</para>
+
+@caps: 
+@nth: 
+@Returns: 
+
+
 <!-- ##### FUNCTION gst_static_caps_get ##### -->
 <para>
 
index b92fdbd..46d8e03 100644 (file)
@@ -35,3 +35,13 @@ Pseudo link pads
 @pad: 
 
 
+<!-- ##### FUNCTION gst_ghost_pad_set_target ##### -->
+<para>
+
+</para>
+
+@gpad: 
+@newtarget: 
+@Returns: 
+
+
index 3fcf8be..0eb813f 100644 (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
index 754519f..08bde28 100644 (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>
 
index 3c7ee19..2fab80c 100644 (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);
 }
index 3c7ee19..2fab80c 100644 (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);
 }
index 23d0a00..dfe9510 100644 (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;
 }