From c05898a169b7eb2b0675ff036474a59d5a0462f4 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 3 Jul 2014 16:44:05 +0200 Subject: [PATCH] composition: The ref the user gave us is our, and we give another to the bin when needed Co-Authored by: Mathieu Duponchelle --- gnl/gnlcomposition.c | 4 ++-- tests/check/gnl/simple.c | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c index 33c00c4481..ff6057b9f7 100644 --- a/gnl/gnlcomposition.c +++ b/gnl/gnlcomposition.c @@ -2454,7 +2454,7 @@ _relink_single_node (GnlComposition * comp, GNode * node, srcpad = GNL_OBJECT_SRC (newobj); - gst_bin_add (GST_BIN (comp->priv->current_bin), GST_ELEMENT_CAST (newobj)); + gst_bin_add (GST_BIN (comp->priv->current_bin), gst_object_ref (newobj)); gst_element_sync_state_with_parent (GST_ELEMENT_CAST (newobj)); translated_seek = gnl_object_translate_incoming_seek (newobj, toplevel_seek); @@ -2750,7 +2750,7 @@ _gnl_composition_add_entry (GnlComposition * comp, GnlObject * object) GST_TIME_ARGS (GNL_OBJECT_START (object)), GST_TIME_ARGS (GNL_OBJECT_STOP (object))); - gst_object_ref (object); + g_object_ref_sink (object); if ((GNL_OBJECT_IS_EXPANDABLE (object)) && g_list_find (priv->expandables, object)) { diff --git a/tests/check/gnl/simple.c b/tests/check/gnl/simple.c index 3f361c40a0..ae244df5fe 100644 --- a/tests/check/gnl/simple.c +++ b/tests/check/gnl/simple.c @@ -36,7 +36,7 @@ test_simplest_full (void) fail_unless (ret); check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND); check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); sink = gst_element_factory_make_or_warn ("fakesink", "sink"); fail_if (sink == NULL); @@ -60,7 +60,7 @@ test_simplest_full (void) bus = gst_element_get_bus (GST_ELEMENT (pipeline)); GST_ERROR ("Setting pipeline to PLAYING"); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE); @@ -147,7 +147,7 @@ test_time_duration_full (void) fail_unless (ret == TRUE); check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); /* Second source */ @@ -157,11 +157,13 @@ test_time_duration_full (void) fail_unless (ret == TRUE); check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND); - ASSERT_OBJECT_REFCOUNT (source2, "source2", 2); + ASSERT_OBJECT_REFCOUNT (source2, "source2", 1); /* Remove first source */ + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); gst_object_ref (source1); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); GST_ERROR_OBJECT (source1, "Num refs : %i", ((GObject *) source1)->ref_count); gnl_composition_remove (GST_BIN (comp), source1); commit_and_wait (comp, &ret); @@ -178,7 +180,7 @@ test_time_duration_full (void) check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND); gst_object_unref (source1); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); gst_object_unref (comp); } @@ -232,11 +234,10 @@ test_one_after_other_full (void) commit_and_wait (comp, &ret); check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); /* Second source */ gnl_composition_add (GST_BIN (comp), source2); - commit_and_wait (comp, &ret); fail_unless (ret); check_start_stop_duration (source1, 0 * GST_SECOND, 1 * GST_SECOND, @@ -245,7 +246,7 @@ test_one_after_other_full (void) 1 * GST_SECOND); check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND); - ASSERT_OBJECT_REFCOUNT (source2, "source2", 2); + ASSERT_OBJECT_REFCOUNT (source2, "source2", 1); sink = gst_element_factory_make_or_warn ("autovideosink", "sink"); fail_if (sink == NULL); @@ -273,7 +274,7 @@ test_one_after_other_full (void) bus = gst_element_get_bus (GST_ELEMENT (pipeline)); GST_DEBUG ("Setting pipeline to PLAYING"); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE); @@ -403,7 +404,7 @@ test_one_under_another_full (void) Duration : 2s Priority : 1 */ - source1 = videotest_gnl_src ("source1", 0, 2 * GST_SECOND, 3, 1); + source1 = videotest_gnl_src ("source1", 0, 2 * GST_SECOND, 18, 1); fail_if (source1 == NULL); check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND); @@ -413,7 +414,7 @@ test_one_under_another_full (void) Duration : 2s Priority : 2 */ - source2 = videotest_gnl_src ("source2", 1 * GST_SECOND, 2 * GST_SECOND, 2, 2); + source2 = videotest_gnl_src ("source2", 1 * GST_SECOND, 2 * GST_SECOND, 0, 2); fail_if (source2 == NULL); check_start_stop_duration (source2, 1 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND); @@ -566,7 +567,7 @@ test_one_bin_after_other_full (void) check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND); check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); /* Second source */ @@ -577,7 +578,7 @@ test_one_bin_after_other_full (void) check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND); - ASSERT_OBJECT_REFCOUNT (source2, "source2", 2); + ASSERT_OBJECT_REFCOUNT (source2, "source2", 1); /* Remove first source */ @@ -595,7 +596,7 @@ test_one_bin_after_other_full (void) check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND); gst_object_unref (source1); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); sink = gst_element_factory_make_or_warn ("fakesink", "sink"); fail_if (sink == NULL); @@ -623,7 +624,7 @@ test_one_bin_after_other_full (void) bus = gst_element_get_bus (GST_ELEMENT (pipeline)); GST_DEBUG ("Setting pipeline to PLAYING"); - ASSERT_OBJECT_REFCOUNT (source1, "source1", 2); + ASSERT_OBJECT_REFCOUNT (source1, "source1", 1); fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);