From 3c958af13cb4a44705d6effa9a4effded48424ae Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sun, 29 Jun 2014 22:35:34 +0200 Subject: [PATCH] Finish fixing tests --- gnl/gnlcomposition.c | 24 +++++++++++++++--------- tests/check/gnl/gnlcomposition.c | 4 ++-- tests/check/gnl/gnloperation.c | 30 +++++++++++++++--------------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c index 8c4ca40551..647a537989 100644 --- a/gnl/gnlcomposition.c +++ b/gnl/gnlcomposition.c @@ -200,7 +200,7 @@ static void compare_relink_single_node (GnlComposition * comp, GNode * node, GNode * oldstack); static gboolean update_pipeline_func (GnlComposition * comp); -static gboolean commit_pipeline_func (GnlComposition *comp); +static gboolean commit_pipeline_func (GnlComposition * comp); /* COMP_REAL_START: actual position to start current playback at. */ @@ -309,7 +309,8 @@ _start_task (GnlComposition * comp) task = comp->task; if (task == NULL) { - task = gst_task_new ((GstTaskFunction) iterate_main_context_func, comp, NULL); + task = + gst_task_new ((GstTaskFunction) iterate_main_context_func, comp, NULL); gst_task_set_lock (task, GET_TASK_LOCK (comp)); GST_INFO_OBJECT (comp, "created task %p", task); comp->task = task; @@ -482,9 +483,10 @@ gnl_composition_class_init (GnlCompositionClass * klass) G_STRUCT_OFFSET (GnlObjectClass, commit_signal_handler), NULL, NULL, NULL, G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN); - _signals[COMMITED_SIGNAL] = g_signal_new ("commited", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + _signals[COMMITED_SIGNAL] = + g_signal_new ("commited", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, + G_TYPE_BOOLEAN); gnlobject_class->commit = gnl_composition_commit_func; } @@ -1861,7 +1863,7 @@ set_child_caps (GValue * item, GValue * ret G_GNUC_UNUSED, GnlObject * comp) } static gboolean -commit_pipeline_func (GnlComposition *comp) +commit_pipeline_func (GnlComposition * comp) { GList *tmp; gboolean commited = FALSE; @@ -1890,8 +1892,12 @@ commit_pipeline_func (GnlComposition *comp) priv->objects_stop = g_list_sort (priv->objects_stop, (GCompareFunc) objects_stop_compare); - /* And update the pipeline at current position if needed */ - update_pipeline_at_current_position (comp); + if (GST_STATE (comp) < GST_STATE_PAUSED) { + update_start_stop_duration (comp); + } else { + /* And update the pipeline at current position if needed */ + update_pipeline_at_current_position (comp); + } COMP_OBJECTS_UNLOCK (comp); GST_ERROR ("emitted signal"); @@ -1935,7 +1941,7 @@ update_pipeline_func (GnlComposition * comp) GST_TIME_ARGS (epos)); gst_element_post_message (GST_ELEMENT_CAST (comp), gst_message_new_segment_done (GST_OBJECT (comp), - priv->segment->format, epos)); + priv->segment->format, epos)); gst_pad_push_event (GNL_OBJECT (comp)->srcpad, gst_event_new_segment_done (priv->segment->format, epos)); } diff --git a/tests/check/gnl/gnlcomposition.c b/tests/check/gnl/gnlcomposition.c index 38afcab38a..af1931b246 100644 --- a/tests/check/gnl/gnlcomposition.c +++ b/tests/check/gnl/gnlcomposition.c @@ -252,9 +252,9 @@ GST_START_TEST (test_simple_adder) fail_unless (gst_bin_add (GST_BIN (composition), gnlsource2)); fail_unless (gst_element_link (composition, fakesink) == TRUE); - GST_DEBUG ("Setting pipeline to PAUSED"); + GST_DEBUG ("Setting pipeline to PLAYING"); - g_signal_emit_by_name (composition, "commit", TRUE, &ret); + commit_and_wait (composition, &ret); fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE); diff --git a/tests/check/gnl/gnloperation.c b/tests/check/gnl/gnloperation.c index 72d6e43b4b..40b7ee5467 100644 --- a/tests/check/gnl/gnloperation.c +++ b/tests/check/gnl/gnloperation.c @@ -166,7 +166,7 @@ GST_START_TEST (test_simple_operation) ASSERT_OBJECT_REFCOUNT (oper, "oper", 1); gst_bin_add (GST_BIN (comp), source); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND); ASSERT_OBJECT_REFCOUNT (source, "source", 1); @@ -174,7 +174,7 @@ GST_START_TEST (test_simple_operation) /* Add operaton */ gst_bin_add (GST_BIN (comp), oper); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND); ASSERT_OBJECT_REFCOUNT (oper, "oper", 1); @@ -190,7 +190,7 @@ GST_START_TEST (test_simple_operation) /* re-add source */ gst_bin_add (GST_BIN (comp), source); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND); gst_object_unref (source); @@ -255,7 +255,7 @@ GST_START_TEST (test_pyramid_operations) ASSERT_OBJECT_REFCOUNT (oper2, "oper2", 1); gst_bin_add (GST_BIN (comp), source); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (source, 0, 10 * GST_SECOND, 10 * GST_SECOND); check_start_stop_duration (comp, 0, 10 * GST_SECOND, 10 * GST_SECOND); @@ -264,7 +264,7 @@ GST_START_TEST (test_pyramid_operations) /* Add operation 1 */ gst_bin_add (GST_BIN (comp), oper1); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (oper1, 4 * GST_SECOND, 6 * GST_SECOND, 2 * GST_SECOND); check_start_stop_duration (comp, 0, 10 * GST_SECOND, 10 * GST_SECOND); @@ -274,7 +274,7 @@ GST_START_TEST (test_pyramid_operations) /* Add operation 2 */ gst_bin_add (GST_BIN (comp), oper2); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (oper2, 2 * GST_SECOND, 8 * GST_SECOND, 6 * GST_SECOND); check_start_stop_duration (comp, 0, 10 * GST_SECOND, 10 * GST_SECOND); @@ -355,25 +355,25 @@ GST_START_TEST (test_pyramid_operations2) /* Add source 1 */ gst_bin_add (GST_BIN (comp), source1); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND); /* Add source 2 */ gst_bin_add (GST_BIN (comp), source2); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND); /* Add operation */ gst_bin_add (GST_BIN (comp), oper); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND); /* Add default */ gst_bin_add (GST_BIN (comp), def); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND); @@ -458,7 +458,7 @@ GST_START_TEST (test_pyramid_operations_expandable) /* Add default */ gst_bin_add (GST_BIN (comp), def); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND); check_start_stop_duration (oper, 0 * GST_SECOND, 6 * GST_SECOND, 6 * GST_SECOND); @@ -551,7 +551,7 @@ GST_START_TEST (test_complex_operations) gst_bin_add (GST_BIN (comp), oper); check_start_stop_duration (comp, 0, 0, 0); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND); ASSERT_OBJECT_REFCOUNT (oper, "oper", 1); @@ -632,14 +632,14 @@ GST_START_TEST (test_complex_operations_bis) /* Add source1 */ gst_bin_add (GST_BIN (comp), source1); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 4 * GST_SECOND, 4 * GST_SECOND); ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); /* Add source2 */ gst_bin_add (GST_BIN (comp), source2); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND); ASSERT_OBJECT_REFCOUNT (source2, "source2", 1); @@ -647,7 +647,7 @@ GST_START_TEST (test_complex_operations_bis) /* Add operaton */ gst_bin_add (GST_BIN (comp), oper); - g_signal_emit_by_name (comp, "commit", TRUE, &ret); + commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 6 * GST_SECOND, 6 * GST_SECOND); /* Since it's expandable, it should have changed to full length */ check_start_stop_duration (oper, 0 * GST_SECOND, 6 * GST_SECOND,