diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2014-01-15 11:26:33 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-01-21 15:00:53 +0100 |
commit | 7011f98d7e9415fc9265654431f2d74051ff138f (patch) | |
tree | e0dbdcb8c0eb13870f3cb966aa2bdbc67384ae8c /tests | |
parent | c702e370911aaa77f92c23e8e0d9b2306cc1c4e0 (diff) |
tests: rtprtx::test_push_forward_seq: 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.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/check/elements/rtprtx.c b/tests/check/elements/rtprtx.c index bf4ded117..c88e2af8d 100644 --- a/tests/check/elements/rtprtx.c +++ b/tests/check/elements/rtprtx.c @@ -212,6 +212,9 @@ GST_START_TEST (test_push_forward_seq) GstEvent *event = NULL; GstRTPBuffer rtp = GST_RTP_BUFFER_INIT; GstBuffer *buffer = (GstBuffer *) node->data; + GList *last_out_buffer; + guint64 end_time; + gboolean res; gst_buffer_ref (buffer); fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK); @@ -226,7 +229,17 @@ GST_START_TEST (test_push_forward_seq) (guint) gst_rtp_buffer_get_payload_type (&rtp), NULL)); gst_rtp_buffer_unmap (&rtp); + /* 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 (gst_pad_push_event (sinkpad, event)); + 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)); + g_mutex_unlock (&check_mutex); } gst_buffer_unref (buffer); ++i; |