appsrc: Store strong references to the expected buffers in the tests

Otherwise the buffers might already be freed as they were only owned by
the GstSample / appsrc and potentially don't survive until the pad
probe, as observed in some CI runs of the tests.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1787>
This commit is contained in:
Sebastian Dröge 2022-02-24 10:09:50 +02:00 committed by GStreamer Marge Bot
parent b41c70aed5
commit 19b638debe

View file

@ -705,6 +705,7 @@ appsrc_pad_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
fail_unless_equals_uint64 (GST_BUFFER_DURATION (recvbuf), fail_unless_equals_uint64 (GST_BUFFER_DURATION (recvbuf),
GST_BUFFER_DURATION (exp_buf)); GST_BUFFER_DURATION (exp_buf));
gst_buffer_unref (exp_buf);
g_list_free1 (*expected); g_list_free1 (*expected);
*expected = next; *expected = next;
} }
@ -817,7 +818,7 @@ GST_START_TEST (test_appsrc_period_with_custom_segment)
sample = gst_sample_new (buffer, NULL, &segment, NULL); sample = gst_sample_new (buffer, NULL, &segment, NULL);
expected = g_list_append (expected, gst_event_new_segment (&segment)); expected = g_list_append (expected, gst_event_new_segment (&segment));
expected = g_list_append (expected, buffer); expected = g_list_append (expected, gst_buffer_ref (buffer));
/* 1st sample includes buffer and segment */ /* 1st sample includes buffer and segment */
fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample) fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample)
@ -832,7 +833,7 @@ GST_START_TEST (test_appsrc_period_with_custom_segment)
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer) = j * GST_SECOND; GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer) = j * GST_SECOND;
GST_BUFFER_DURATION (buffer) = GST_SECOND; GST_BUFFER_DURATION (buffer) = GST_SECOND;
expected = g_list_append (expected, buffer); expected = g_list_append (expected, gst_buffer_ref (buffer));
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src), buffer) fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src), buffer)
== GST_FLOW_OK); == GST_FLOW_OK);
} }
@ -869,7 +870,7 @@ GST_START_TEST (test_appsrc_period_with_custom_segment)
sample = gst_sample_new (buffer, NULL, &segment, NULL); sample = gst_sample_new (buffer, NULL, &segment, NULL);
expected = g_list_append (expected, gst_event_new_segment (&segment)); expected = g_list_append (expected, gst_event_new_segment (&segment));
expected = g_list_append (expected, buffer); expected = g_list_append (expected, gst_buffer_ref (buffer));
/* 1st sample includes buffer and segment */ /* 1st sample includes buffer and segment */
fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample) fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample)
@ -884,7 +885,7 @@ GST_START_TEST (test_appsrc_period_with_custom_segment)
buffer = gst_buffer_new_and_alloc (4); buffer = gst_buffer_new_and_alloc (4);
GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer) = j * GST_SECOND; GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer) = j * GST_SECOND;
GST_BUFFER_DURATION (buffer) = GST_SECOND; GST_BUFFER_DURATION (buffer) = GST_SECOND;
expected = g_list_append (expected, buffer); expected = g_list_append (expected, gst_buffer_ref (buffer));
fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src), buffer) fail_unless (gst_app_src_push_buffer (GST_APP_SRC (src), buffer)
== GST_FLOW_OK); == GST_FLOW_OK);
} }
@ -999,7 +1000,7 @@ GST_START_TEST (test_appsrc_custom_segment_twice)
} else { } else {
sample = gst_sample_new (buffer, NULL, &segment, NULL); sample = gst_sample_new (buffer, NULL, &segment, NULL);
expected = g_list_append (expected, gst_event_new_segment (&segment)); expected = g_list_append (expected, gst_event_new_segment (&segment));
expected = g_list_append (expected, buffer); expected = g_list_append (expected, gst_buffer_ref (buffer));
} }
/* PUSH THE FIRST SAMPLE */ /* PUSH THE FIRST SAMPLE */
fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample) fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample)
@ -1024,11 +1025,11 @@ GST_START_TEST (test_appsrc_custom_segment_twice)
if (tc == 0 || tc == 1) { if (tc == 0 || tc == 1) {
/* Test Case 0 or 1: Push a sample with duplicated segment */ /* Test Case 0 or 1: Push a sample with duplicated segment */
sample = gst_sample_new (buffer, NULL, &segment, NULL); sample = gst_sample_new (buffer, NULL, &segment, NULL);
expected = g_list_append (expected, buffer); expected = g_list_append (expected, gst_buffer_ref (buffer));
} else { } else {
sample = gst_sample_new (buffer, NULL, &segment, NULL); sample = gst_sample_new (buffer, NULL, &segment, NULL);
expected = g_list_append (expected, gst_event_new_segment (&segment)); expected = g_list_append (expected, gst_event_new_segment (&segment));
expected = g_list_append (expected, buffer); expected = g_list_append (expected, gst_buffer_ref (buffer));
} }
fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample) fail_unless (gst_app_src_push_sample (GST_APP_SRC (src), sample)