[igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test

Simon Ser simon.ser at intel.com
Wed May 29 13:32:50 UTC 2019


Make sure adding a pop in the input signal makes audio_signal_detect fail.

Signed-off-by: Simon Ser <simon.ser at intel.com>
---
 lib/tests/igt_audio.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
index 0f1c39d93728..214dcea73efc 100644
--- a/lib/tests/igt_audio.c
+++ b/lib/tests/igt_audio.c
@@ -111,6 +111,26 @@ static void test_signal_detect_extra(struct audio_signal *signal)
 	igt_assert(!ok);
 }
 
+static void test_signal_detect_pop(struct audio_signal *signal)
+{
+	double *buf;
+	bool ok;
+	size_t i;
+
+	buf = malloc(BUFFER_LEN * sizeof(double));
+	audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
+
+	/* Add a discontinuity in the signal */
+	for (i = 0; i < 5; i++)
+		buf[BUFFER_LEN / 3 + i] = 0.9;
+
+	ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+
+	free(buf);
+
+	igt_assert(!ok);
+}
+
 igt_main
 {
 	struct audio_signal *signal;
@@ -146,6 +166,9 @@ igt_main
 		igt_subtest("signal-detect-extra")
 			test_signal_detect_extra(signal);
 
+		igt_subtest("signal-detect-pop")
+			test_signal_detect_pop(signal);
+
 		igt_fixture {
 			audio_signal_fini(signal);
 		}
-- 
2.21.0



More information about the igt-dev mailing list