tests: compositor: Fix race in buffer unref

Don't assume that compositor will output only single buffer
for single input buffer. If buffer's running time is not completly
aligned to output buffer running time or duration, compositor
can generate multiple buffers. If that happens, two threads,
one is aggregator output thread and main thread were trying
to modify buffer in this test. Clear the buffer after
shutting down pipeline to avoid the race.

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2836
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5081>
This commit is contained in:
Seungha Yang 2023-07-21 00:47:32 +09:00
parent 3a5978def1
commit 792eb0cf48

View file

@ -2627,12 +2627,12 @@ GST_START_TEST (test_stream_start_after_eos)
while (!test_data.buf) while (!test_data.buf)
g_cond_wait (&test_data.cond, &test_data.lock); g_cond_wait (&test_data.cond, &test_data.lock);
g_mutex_unlock (&test_data.lock); g_mutex_unlock (&test_data.lock);
gst_buffer_unref (test_data.buf);
state_res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* cleanup */ /* cleanup */
gst_buffer_unref (test_data.buf);
g_main_loop_unref (main_loop); g_main_loop_unref (main_loop);
gst_bus_remove_signal_watch (bus); gst_bus_remove_signal_watch (bus);
gst_object_unref (bus); gst_object_unref (bus);
@ -2728,12 +2728,12 @@ GST_START_TEST (test_new_pad_after_eos)
while (!test_data.buf) while (!test_data.buf)
g_cond_wait (&test_data.cond, &test_data.lock); g_cond_wait (&test_data.cond, &test_data.lock);
g_mutex_unlock (&test_data.lock); g_mutex_unlock (&test_data.lock);
gst_buffer_unref (test_data.buf);
state_res = gst_element_set_state (bin, GST_STATE_NULL); state_res = gst_element_set_state (bin, GST_STATE_NULL);
ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE);
/* cleanup */ /* cleanup */
gst_buffer_unref (test_data.buf);
g_main_loop_unref (main_loop); g_main_loop_unref (main_loop);
gst_bus_remove_signal_watch (bus); gst_bus_remove_signal_watch (bus);
gst_object_unref (bus); gst_object_unref (bus);