From e5fc41b102ec50210646449822cb7f2f81d7f99a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 23 Apr 2019 16:04:53 +0300 Subject: tests/kms_chamelium: capture audio data in real-time Before this patch, the audio test first sends an audio signal for 2s, and then checks whether the captured signal matches. This patch makes it so we send and check the signal in parallel. Thus we can stop the test as soon as we receive the correct signal. This saves ~2s per audio test. Signed-off-by: Simon Ser Reviewed-by: Martin Peres --- lib/igt_alsa.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/igt_alsa.c b/lib/igt_alsa.c index 22089881..fc6d336b 100644 --- a/lib/igt_alsa.c +++ b/lib/igt_alsa.c @@ -497,7 +497,8 @@ void alsa_register_input_callback(struct alsa *alsa, /** * alsa_run: * @alsa: The target alsa structure - * @duration_ms: The maximum duration of the run in milliseconds + * @duration_ms: The maximum duration of the run in milliseconds, or -1 for an + * infinite duration. * * Run ALSA playback and capture on the input and output devices for at * most @duration_ms milliseconds, calling the registered callbacks when needed. @@ -545,7 +546,7 @@ int alsa_run(struct alsa *alsa, int duration_ms) do { reached = true; - if (output_total < output_limit) { + if (output_limit < 0 || output_total < output_limit) { reached = false; if (!output_ready) { @@ -607,7 +608,8 @@ int alsa_run(struct alsa *alsa, int duration_ms) } - if (alsa->input_callback && input_total < input_limit) { + if (alsa->input_callback && + (input_limit < 0 || input_total < input_limit)) { reached = false; if (input_count == input_trigger) { @@ -660,11 +662,8 @@ int alsa_run(struct alsa *alsa, int duration_ms) ret = 0; complete: - if (output_buffer) - free(output_buffer); - - if (input_buffer) - free(input_buffer); + free(output_buffer); + free(input_buffer); return ret; } -- cgit v1.2.3