summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2021-05-26 22:50:22 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2021-05-27 16:33:00 -0400
commit78e7612eb0707cda85baa0d2848b66e468ae7929 (patch)
treef693e4d793f5d9265934f01be6afd55a51c3530e
parentfd73fd05caa3a459795cc3061ceaa65afcba820a (diff)
audiomixer: Add test for discont going backwards
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1180>
-rw-r--r--tests/check/elements/audiomixer.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/check/elements/audiomixer.c b/tests/check/elements/audiomixer.c
index b88575566..4c89d610c 100644
--- a/tests/check/elements/audiomixer.c
+++ b/tests/check/elements/audiomixer.c
@@ -1452,6 +1452,83 @@ GST_START_TEST (test_sync_discont)
GST_END_TEST;
+
+static void
+send_buffers_sync_discont_backwards (GstPad * pad1, GstPad * pad2)
+{
+ GstBuffer *buffer;
+ GstFlowReturn ret;
+
+ buffer = new_buffer (2300, 1, 1 * GST_SECOND, 1.25 * GST_SECOND, 0);
+ ret = gst_pad_chain (pad1, buffer);
+ ck_assert_int_eq (ret, GST_FLOW_OK);
+
+ buffer = new_buffer (2000, 1, 2 * GST_SECOND, 1 * GST_SECOND,
+ GST_BUFFER_FLAG_DISCONT);
+ ret = gst_pad_chain (pad1, buffer);
+ ck_assert_int_eq (ret, GST_FLOW_OK);
+
+ gst_pad_send_event (pad1, gst_event_new_eos ());
+
+ buffer = new_buffer (2000, 1, 2 * GST_SECOND, 1 * GST_SECOND, 0);
+ ret = gst_pad_chain (pad2, buffer);
+ ck_assert_int_eq (ret, GST_FLOW_OK);
+
+
+ gst_pad_send_event (pad2, gst_event_new_eos ());
+}
+
+static void
+check_buffers_sync_discont_backwards (GList * received_buffers)
+{
+ GstBuffer *buffer;
+ GList *l;
+ gint i;
+ GstMapInfo map;
+
+ /* Should have 6 * 0.5s buffers */
+ fail_unless_equals_int (g_list_length (received_buffers), 6);
+ for (i = 0, l = received_buffers; l; l = l->next, i++) {
+ buffer = l->data;
+
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+
+ if (i == 0 && GST_BUFFER_TIMESTAMP (buffer) == 0) {
+ fail_unless (map.data[0] == 0);
+ fail_unless (map.data[map.size - 1] == 0);
+ } else if (i == 1 && GST_BUFFER_TIMESTAMP (buffer) == 500 * GST_MSECOND) {
+ fail_unless (map.data[0] == 0);
+ fail_unless (map.data[map.size - 1] == 0);
+ } else if (i == 2 && GST_BUFFER_TIMESTAMP (buffer) == 1000 * GST_MSECOND) {
+ fail_unless (map.data[0] == 1);
+ fail_unless (map.data[map.size - 1] == 1);
+ } else if (i == 3 && GST_BUFFER_TIMESTAMP (buffer) == 1500 * GST_MSECOND) {
+ fail_unless (map.data[0] == 1);
+ fail_unless (map.data[map.size - 1] == 1);
+ } else if (i == 4 && GST_BUFFER_TIMESTAMP (buffer) == 2000 * GST_MSECOND) {
+ fail_unless (map.data[0] == 2);
+ fail_unless (map.data[map.size - 1] == 2);
+ } else if (i == 5 && GST_BUFFER_TIMESTAMP (buffer) == 2500 * GST_MSECOND) {
+ fail_unless (map.data[0] == 2);
+ fail_unless (map.data[map.size - 1] == 2);
+ } else {
+ g_assert_not_reached ();
+ }
+
+ gst_buffer_unmap (buffer, &map);
+
+ }
+}
+
+GST_START_TEST (test_sync_discont_backwards)
+{
+ run_sync_test (send_buffers_sync_discont_backwards,
+ check_buffers_sync_discont_backwards);
+}
+
+GST_END_TEST;
+
+
static void
send_buffers_sync_unaligned (GstPad * pad1, GstPad * pad2)
{
@@ -1969,6 +2046,7 @@ audiomixer_suite (void)
tcase_add_test (tc_chain, test_flush_start_flush_stop);
tcase_add_test (tc_chain, test_sync);
tcase_add_test (tc_chain, test_sync_discont);
+ tcase_add_test (tc_chain, test_sync_discont_backwards);
tcase_add_test (tc_chain, test_sync_unaligned);
tcase_add_test (tc_chain, test_segment_base_handling);
tcase_add_test (tc_chain, test_sinkpad_property_controller);