summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-04-23 16:04:53 +0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-04-25 13:07:37 +0300
commite5fc41b102ec50210646449822cb7f2f81d7f99a (patch)
tree402637a2561b8ba65997687e41e5acad440202f7 /lib
parent311baff151f90c1db6f57ee9515216b4f9da5db7 (diff)
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 <simon.ser@intel.com> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_alsa.c15
1 files changed, 7 insertions, 8 deletions
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;
}