diff options
author | Alessandro Decina <alessandro.decina@collabora.co.uk> | 2010-08-19 15:10:25 +0200 |
---|---|---|
committer | Alessandro Decina <alessandro.decina@collabora.co.uk> | 2010-08-20 10:31:38 +0200 |
commit | 00b4bfa48f23e671b40c36e428ebfc224f0e3c9c (patch) | |
tree | ad9efabb9f8e0f9d8e70f3bfcab921e68d5416c9 | |
parent | d246e0c592fa6222c2003c59b2dd1026b905933d (diff) |
gnlcomposition: fail early in remove_object when removing an invalid object.
Make gnl_composition_remove_object return immediately FALSE when removing an
object not contained in the composition.
-rw-r--r-- | gnl/gnlcomposition.c | 15 | ||||
-rw-r--r-- | tests/check/gnl/gnlcomposition.c | 20 |
2 files changed, 29 insertions, 6 deletions
diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c index 1c4e62d..fe16f6d 100644 --- a/gnl/gnlcomposition.c +++ b/gnl/gnlcomposition.c | |||
@@ -2609,6 +2609,12 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element) | |||
2609 | 2609 | ||
2610 | COMP_OBJECTS_LOCK (comp); | 2610 | COMP_OBJECTS_LOCK (comp); |
2611 | 2611 | ||
2612 | entry = COMP_ENTRY (comp, element); | ||
2613 | if (entry == NULL) { | ||
2614 | COMP_OBJECTS_UNLOCK (comp); | ||
2615 | goto out; | ||
2616 | } | ||
2617 | |||
2612 | gst_object_ref (element); | 2618 | gst_object_ref (element); |
2613 | 2619 | ||
2614 | gst_element_set_locked_state (element, FALSE); | 2620 | gst_element_set_locked_state (element, FALSE); |
@@ -2629,8 +2635,7 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element) | |||
2629 | GST_LOG_OBJECT (element, "Removed from the objects start/stop list"); | 2635 | GST_LOG_OBJECT (element, "Removed from the objects start/stop list"); |
2630 | } | 2636 | } |
2631 | 2637 | ||
2632 | if (!(g_hash_table_remove (comp->priv->objects_hash, element))) | 2638 | g_hash_table_remove (comp->priv->objects_hash, element); |
2633 | goto chiringuito; | ||
2634 | 2639 | ||
2635 | update_required = OBJECT_IN_ACTIVE_SEGMENT (comp, element) || | 2640 | update_required = OBJECT_IN_ACTIVE_SEGMENT (comp, element) || |
2636 | (GNL_OBJECT_PRIORITY (element) == G_MAXUINT32) || | 2641 | (GNL_OBJECT_PRIORITY (element) == G_MAXUINT32) || |
@@ -2671,9 +2676,7 @@ beach: | |||
2671 | } | 2676 | } |
2672 | 2677 | ||
2673 | gst_object_unref (element); | 2678 | gst_object_unref (element); |
2674 | return ret; | ||
2675 | 2679 | ||
2676 | chiringuito: | 2680 | out: |
2677 | COMP_OBJECTS_UNLOCK (comp); | 2681 | return ret; |
2678 | goto beach; | ||
2679 | } | 2682 | } |
diff --git a/tests/check/gnl/gnlcomposition.c b/tests/check/gnl/gnlcomposition.c index dcb4f1a..9063a1c 100644 --- a/tests/check/gnl/gnlcomposition.c +++ b/tests/check/gnl/gnlcomposition.c | |||
@@ -214,6 +214,25 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack) | |||
214 | 214 | ||
215 | GST_END_TEST; | 215 | GST_END_TEST; |
216 | 216 | ||
217 | GST_START_TEST (test_remove_invalid_object) | ||
218 | { | ||
219 | GstBin *composition; | ||
220 | GstElement *source1, *source2; | ||
221 | |||
222 | composition = GST_BIN (gst_element_factory_make ("gnlcomposition", | ||
223 | "composition")); | ||
224 | source1 = gst_element_factory_make ("gnlsource", "source1"); | ||
225 | source2 = gst_element_factory_make ("gnlsource", "source2"); | ||
226 | |||
227 | gst_bin_add (composition, source1); | ||
228 | fail_if (gst_bin_remove (composition, source2)); | ||
229 | fail_unless (gst_bin_remove (composition, source1)); | ||
230 | |||
231 | gst_object_unref (composition); | ||
232 | } | ||
233 | |||
234 | GST_END_TEST; | ||
235 | |||
217 | Suite * | 236 | Suite * |
218 | gnonlin_suite (void) | 237 | gnonlin_suite (void) |
219 | { | 238 | { |
@@ -223,6 +242,7 @@ gnonlin_suite (void) | |||
223 | suite_add_tcase (s, tc_chain); | 242 | suite_add_tcase (s, tc_chain); |
224 | 243 | ||
225 | tcase_add_test (tc_chain, test_change_object_start_stop_in_current_stack); | 244 | tcase_add_test (tc_chain, test_change_object_start_stop_in_current_stack); |
245 | tcase_add_test (tc_chain, test_remove_invalid_object); | ||
226 | 246 | ||
227 | return s; | 247 | return s; |
228 | } | 248 | } |