summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2014-01-15 17:27:19 +0100
committerWim Taymans <wtaymans@redhat.com>2014-01-21 15:00:53 +0100
commit184553151da57dd6d760fdb1881a6b32046467c3 (patch)
tree818d24d192d38c199c9f7cfeed3e3581b6782c15 /tests
parent7677aec2faa0844dd35c5d94445f0b9849b717b1 (diff)
tests: rtprtx::test_rtxreceive_data_reconstruction: fix race condition
Now with rtprtxsend pushing rtx buffers from a different thread, this is necessary to ensure that the result of the test is deterministic. This code makes use of GstCheck's global GMutex and GCond that are being used inside GstCheck's sink pad chain() function in order to synchronize with it.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/rtprtx.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/check/elements/rtprtx.c b/tests/check/elements/rtprtx.c
index a1ddcbfe5..759786e70 100644
--- a/tests/check/elements/rtprtx.c
+++ b/tests/check/elements/rtprtx.c
@@ -1447,12 +1447,31 @@ GST_START_TEST (test_rtxreceive_data_reconstruction)
gst_check_setup_events (srcpad, rtxsend, caps, GST_FORMAT_TIME);
gst_caps_unref (caps);
- /* push buffer and retransmission request */
+ /* push buffer */
buffer = gst_buffer_ref (GST_BUFFER (in_buffers->data));
fail_unless_equals_int (gst_pad_push (srcpad, gst_buffer_ref (buffer)),
GST_FLOW_OK);
- fail_unless_equals_int (gst_pad_push_event (sinkpad,
- create_rtx_event (1, ssrc, payload_type)), TRUE);
+
+ /* push retransmission request */
+ {
+ GList *last_out_buffer;
+ guint64 end_time;
+ gboolean res;
+
+ /* synchronize with the chain() function of the "sinkpad"
+ * to make sure that rtxsend has pushed the rtx buffer out
+ * before continuing */
+ last_out_buffer = g_list_last (buffers);
+ g_mutex_lock (&check_mutex);
+ fail_unless_equals_int (gst_pad_push_event (sinkpad,
+ create_rtx_event (1, ssrc, payload_type)), TRUE);
+ end_time = g_get_monotonic_time () + G_TIME_SPAN_SECOND;
+ do
+ res = g_cond_wait_until (&check_cond, &check_mutex, end_time);
+ while (res == TRUE && last_out_buffer == g_list_last (buffers));
+ fail_unless_equals_int (res, TRUE);
+ g_mutex_unlock (&check_mutex);
+ }
/* push with the next seqnum to trigger retransmission in rtxsend */
buffer = gst_buffer_make_writable (buffer);