diff --git a/ChangeLog b/ChangeLog index 6407d2fda2..00b4492e2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-04-11 Stefan Kost + + * docs/libs/gstreamer-libs-sections.txt: + * libs/gst/controller/gstcontroller.c: (gst_controller_unset), + (gst_controller_unset_all): + * libs/gst/controller/gstcontroller.h: + Added new method _unset_all() and fixed _unset() + + * tests/check/libs/controller.c: (GST_START_TEST), + (gst_controller_suite): + Added two testcases for new and fixed method + 2006-04-11 Tim-Philipp Müller * libs/gst/net/gstnettimepacket.c: (gst_net_time_packet_send): diff --git a/docs/libs/gstreamer-libs-sections.txt b/docs/libs/gstreamer-libs-sections.txt index 762098929a..847aadd5bc 100644 --- a/docs/libs/gstreamer-libs-sections.txt +++ b/docs/libs/gstreamer-libs-sections.txt @@ -58,6 +58,7 @@ gst_controller_remove_properties_valist gst_controller_set gst_controller_set_from_list gst_controller_unset +gst_controller_unset_all gst_controller_get gst_controller_get_all gst_controller_sync_values diff --git a/libs/gst/controller/gstcontroller.c b/libs/gst/controller/gstcontroller.c index f8802bc289..1bbfcbe76c 100644 --- a/libs/gst/controller/gstcontroller.c +++ b/libs/gst/controller/gstcontroller.c @@ -787,7 +787,44 @@ gst_controller_unset (GstController * self, gchar * property_name, g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { - prop->values = g_list_remove (prop->values, prop); + GList *node; + + /* check if a timed_value for the timestamp exists */ + if ((node = g_list_find_custom (prop->values, ×tamp, + gst_timed_value_find))) { + prop->values = g_list_delete_link (prop->values, node); + res = TRUE; + } + } + g_mutex_unlock (self->lock); + + return (res); +} + +/** + * gst_controller_unset_all: + * @self: the controller object which handles the properties + * @property_name: the name of the property to unset + * + * Used to remove all time-stamped values of given controller-handled property + * + * Returns: %FALSE if the values couldn't be unset (ex : properties not handled + * by controller), %TRUE otherwise + * Since: 0.10.5 + */ +gboolean +gst_controller_unset_all (GstController * self, gchar * property_name) +{ + gboolean res = FALSE; + GstControlledProperty *prop; + + g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); + g_return_val_if_fail (property_name, FALSE); + + g_mutex_lock (self->lock); + if ((prop = gst_controller_find_controlled_property (self, property_name))) { + g_list_free (prop->values); + prop->values = NULL; res = TRUE; } g_mutex_unlock (self->lock); diff --git a/libs/gst/controller/gstcontroller.h b/libs/gst/controller/gstcontroller.h index fbb7752645..05200ae7ba 100644 --- a/libs/gst/controller/gstcontroller.h +++ b/libs/gst/controller/gstcontroller.h @@ -159,7 +159,7 @@ gboolean gst_controller_set_from_list (GstController * self, gboolean gst_controller_unset (GstController * self, gchar * property_name, GstClockTime timestamp); - +gboolean gst_controller_unset_all (GstController * self, gchar * property_name); GValue *gst_controller_get (GstController * self, gchar * property_name, GstClockTime timestamp); diff --git a/tests/check/libs/controller.c b/tests/check/libs/controller.c index 030943285a..49aca146ac 100644 --- a/tests/check/libs/controller.c +++ b/tests/check/libs/controller.c @@ -566,6 +566,107 @@ GST_START_TEST (controller_interpolate_linear) GST_END_TEST; +/* test _unset() */ +GST_START_TEST (controller_unset) +{ + GstController *ctrl; + GstElement *elem; + gboolean res; + GValue val_ulong = { 0, }; + + elem = gst_element_factory_make ("testmonosource", "test_source"); + + /* that property should exist and should be controllable */ + ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); + fail_unless (ctrl != NULL, NULL); + + /* set interpolation mode */ + gst_controller_set_interpolation_mode (ctrl, "ulong", GST_INTERPOLATE_NONE); + + /* set control values */ + g_value_init (&val_ulong, G_TYPE_ULONG); + g_value_set_ulong (&val_ulong, 0); + res = gst_controller_set (ctrl, "ulong", 0 * GST_SECOND, &val_ulong); + fail_unless (res, NULL); + g_value_set_ulong (&val_ulong, 100); + res = gst_controller_set (ctrl, "ulong", 1 * GST_SECOND, &val_ulong); + fail_unless (res, NULL); + g_value_set_ulong (&val_ulong, 50); + res = gst_controller_set (ctrl, "ulong", 2 * GST_SECOND, &val_ulong); + fail_unless (res, NULL); + + /* verify values */ + gst_controller_sync_values (ctrl, 0 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL); + gst_controller_sync_values (ctrl, 1 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL); + gst_controller_sync_values (ctrl, 2 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL); + + /* unset second */ + res = gst_controller_unset (ctrl, "ulong", 1 * GST_SECOND); + fail_unless (res, NULL); + + /* verify value again */ + gst_controller_sync_values (ctrl, 1 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL); + gst_controller_sync_values (ctrl, 2 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL); + + GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); + g_object_unref (ctrl); + gst_object_unref (elem); +} + +GST_END_TEST; + +/* test _unset_all() */ +GST_START_TEST (controller_unset_all) +{ + GstController *ctrl; + GstElement *elem; + gboolean res; + GValue val_ulong = { 0, }; + + elem = gst_element_factory_make ("testmonosource", "test_source"); + + /* that property should exist and should be controllable */ + ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); + fail_unless (ctrl != NULL, NULL); + + /* set interpolation mode */ + gst_controller_set_interpolation_mode (ctrl, "ulong", GST_INTERPOLATE_NONE); + + /* set control values */ + g_value_init (&val_ulong, G_TYPE_ULONG); + g_value_set_ulong (&val_ulong, 0); + res = gst_controller_set (ctrl, "ulong", 0 * GST_SECOND, &val_ulong); + fail_unless (res, NULL); + g_value_set_ulong (&val_ulong, 100); + res = gst_controller_set (ctrl, "ulong", 1 * GST_SECOND, &val_ulong); + fail_unless (res, NULL); + + /* verify values */ + gst_controller_sync_values (ctrl, 0 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL); + gst_controller_sync_values (ctrl, 1 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL); + + /* unset second */ + res = gst_controller_unset_all (ctrl, "ulong"); + fail_unless (res, NULL); + + /* verify value again */ + gst_controller_sync_values (ctrl, 1 * GST_SECOND); + fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL); + + GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); + g_object_unref (ctrl); + gst_object_unref (elem); +} + +GST_END_TEST; + /* tests if we can run helper methods against any GObject */ GST_START_TEST (controller_helper_any_gobject) { @@ -605,6 +706,8 @@ gst_controller_suite (void) tcase_add_test (tc, controller_interpolate_none); tcase_add_test (tc, controller_interpolate_trigger); tcase_add_test (tc, controller_interpolate_linear); + tcase_add_test (tc, controller_unset); + tcase_add_test (tc, controller_unset_all); tcase_add_test (tc, controller_helper_any_gobject); return s;