tests: Avoid hang with decodebin test
authorEdward Hervey <edward@centricular.com>
Mon, 8 Jun 2020 06:11:00 +0000 (08:11 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Mon, 8 Jun 2020 06:11:00 +0000 (08:11 +0200)
When adding elements dynamically to a pipeline one should never guess what the
curren/target state is, and instead use `gst_element_sync_state_with_parent()`.

Fixes racy hang when running within valgrind

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/692>

tests/check/elements/decodebin.c

index 86d004e..f27fb7c 100644 (file)
@@ -127,12 +127,11 @@ pad_added_plug_fakesink_cb (GstElement * decodebin, GstPad * srcpad,
   fail_unless (sink != NULL, "Failed to create fakesink element");
 
   gst_bin_add (GST_BIN (pipeline), sink);
+  gst_element_sync_state_with_parent (sink);
 
   sinkpad = gst_element_get_static_pad (sink, "sink");
   fail_unless_equals_int (gst_pad_link (srcpad, sinkpad), GST_PAD_LINK_OK);
   gst_object_unref (sinkpad);
-
-  gst_element_set_state (sink, GST_STATE_PLAYING);
 }
 
 GST_START_TEST (test_reuse_without_decoders)