From: Nicolas Dufresne Date: Fri, 7 Aug 2015 19:39:59 +0000 (-0400) Subject: basesrc-test: Fix race testing segment update X-Git-Tag: 1.6.1~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=900110c6dcb1b8f0c2203e1ee586b7c19dbd3eda;p=platform%2Fupstream%2Fgstreamer.git basesrc-test: Fix race testing segment update As this test is using a short sleep (GST_USECOND, which is 10ms in microsecond), sometimes that EOS event is received before the loop in basesrc have run _do_seek() and pushed the update segment. To solve this issue, we wait for the initial segment (and flush it) then we wait for the second segment before sending EOS. https://bugzilla.gnome.org/show_bug.cgi?id=753365 --- diff --git a/tests/check/libs/basesrc.c b/tests/check/libs/basesrc.c index 9602b4c..82c6589 100644 --- a/tests/check/libs/basesrc.c +++ b/tests/check/libs/basesrc.c @@ -510,9 +510,11 @@ segment_event_catcher (GstObject * pad, GstPadProbeInfo * info, fail_unless (user_data != NULL); if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) { - if (*last_event) - gst_event_unref (*last_event); + g_mutex_lock (&check_mutex); + fail_unless (*last_event == NULL); *last_event = gst_event_copy (event); + g_cond_signal (&check_cond); + g_mutex_unlock (&check_mutex); } return GST_PAD_PROBE_OK; @@ -568,14 +570,26 @@ GST_START_TEST (basesrc_seek_events_rate_update) state_ret = gst_element_get_state (pipe, NULL, NULL, -1); fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS); + /* wait for the first segment to be posted, and flush it ... */ + g_mutex_lock (&check_mutex); + while (seg_event == NULL) + g_cond_wait (&check_cond, &check_mutex); + gst_event_unref (seg_event); + seg_event = NULL; + g_mutex_unlock (&check_mutex); + GST_INFO ("seeking"); /* seek */ event_ret = gst_element_send_event (pipe, rate_seek); fail_unless (event_ret == TRUE); - /* wait a second, then do controlled shutdown */ - g_usleep (GST_USECOND * 1); + /* wait for the updated segment to be posted, posting EOS make the loop + * thread exit before the updated segment is posted ... */ + g_mutex_lock (&check_mutex); + while (seg_event == NULL) + g_cond_wait (&check_cond, &check_mutex); + g_mutex_unlock (&check_mutex); /* shut down pipeline only (should send EOS message) ... */ gst_element_send_event (pipe, gst_event_new_eos ());