mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
libs/gst/controller/gstcontroller.c: some little tuning
Original commit message from CVS: * libs/gst/controller/gstcontroller.c: (gst_controller_sync_values): some little tuning * tests/check/libs/controller.c: (GST_START_TEST), (gst_controller_suite): a new test for live value handling
This commit is contained in:
parent
37cb1aaa57
commit
992e992730
3 changed files with 66 additions and 3 deletions
|
@ -1,3 +1,12 @@
|
|||
2006-04-28 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* libs/gst/controller/gstcontroller.c:
|
||||
(gst_controller_sync_values):
|
||||
some little tuning
|
||||
* tests/check/libs/controller.c: (GST_START_TEST),
|
||||
(gst_controller_suite):
|
||||
a new test for live value handling
|
||||
|
||||
2006-04-28 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
Patch by: Topi Paavola
|
||||
|
|
|
@ -930,10 +930,10 @@ gst_controller_sync_values (GstController * self, GstClockTime timestamp)
|
|||
timestamp);
|
||||
|
||||
live = FALSE;
|
||||
if (G_IS_VALUE (&prop->live_value.value)) {
|
||||
if (G_UNLIKELY (G_IS_VALUE (&prop->live_value.value))) {
|
||||
GList *lnode =
|
||||
gst_controlled_property_find_timed_value_node (prop, timestamp);
|
||||
if (!lnode) {
|
||||
if (G_UNLIKELY (!lnode)) {
|
||||
GST_DEBUG (" no control changes in the queue");
|
||||
live = TRUE;
|
||||
} else {
|
||||
|
@ -947,7 +947,7 @@ gst_controller_sync_values (GstController * self, GstClockTime timestamp)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!live) {
|
||||
if (G_LIKELY (!live)) {
|
||||
/* get current value via interpolator */
|
||||
value = prop->get (prop, timestamp);
|
||||
prop->last_value.timestamp = timestamp;
|
||||
|
|
|
@ -667,6 +667,59 @@ GST_START_TEST (controller_unset_all)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
/* test live value handling */
|
||||
GST_START_TEST (controller_live)
|
||||
{
|
||||
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_LINEAR);
|
||||
|
||||
/* 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", 4 * GST_SECOND, &val_ulong);
|
||||
fail_unless (res, NULL);
|
||||
g_value_set_ulong (&val_ulong, 200);
|
||||
res = gst_controller_set (ctrl, "ulong", 8 * GST_SECOND, &val_ulong);
|
||||
fail_unless (res, NULL);
|
||||
|
||||
/* verify value */
|
||||
gst_controller_sync_values (ctrl, 2 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);
|
||||
|
||||
/* set live value */
|
||||
g_object_set (elem, "ulong", 500, NULL);
|
||||
|
||||
/* we should still get the live value */
|
||||
gst_controller_sync_values (ctrl, 3 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 500, NULL);
|
||||
|
||||
/* we should not get the live value anymore */
|
||||
gst_controller_sync_values (ctrl, 4 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
|
||||
gst_controller_sync_values (ctrl, 6 * GST_SECOND);
|
||||
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 150, 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)
|
||||
{
|
||||
|
@ -708,6 +761,7 @@ gst_controller_suite (void)
|
|||
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_live);
|
||||
tcase_add_test (tc, controller_helper_any_gobject);
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Reference in a new issue