webrtcbin test: Fix race in new test
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Mon, 21 Jun 2021 20:50:46 +0000 (16:50 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 24 Jun 2021 09:41:09 +0000 (09:41 +0000)
Pull a buffer from a sink to make sure that the caps are already
set before trying to update them.

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

tests/check/elements/webrtcbin.c

index 405886ee3f87f6526e0c0a3ed12474047949281c..a1253f07a12d59cdae35cf6ac977e75179860218 100644 (file)
@@ -4074,6 +4074,7 @@ GST_START_TEST (test_codec_preferences_negotiation_srcpad)
   GstHarness *sink_harness = NULL;
   guint i;
   GstElement *rtpbin2;
+  GstBuffer *buf;
 
   t->on_negotiation_needed = NULL;
   t->on_ice_candidate = NULL;
@@ -4108,6 +4109,13 @@ GST_START_TEST (test_codec_preferences_negotiation_srcpad)
   g_mutex_unlock (&t->lock);
   fail_unless (sink_harness->element == t->webrtc2);
 
+  /* Get one buffer out, this makes sure the capsfilter is primed and
+   * avoids races.
+   */
+  buf = gst_harness_pull (sink_harness);
+  fail_unless (buf != NULL);
+  gst_buffer_unref (buf);
+
   gst_harness_set_sink_caps_str (sink_harness, OPUS_RTP_CAPS (100));
 
   test_webrtc_reset_negotiation (t);