mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
Added new method _unset_all() and fixed _unset()
Original commit message from CVS: * 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
This commit is contained in:
parent
7916e14a25
commit
3512929a5c
5 changed files with 155 additions and 2 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2006-04-11 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* 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 <tim at centricular dot net>
|
||||
|
||||
* libs/gst/net/gstnettimepacket.c: (gst_net_time_packet_send):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue