From 2bfb40c2ae316c2d4f07d3afa4c33140becdd5a2 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 11 Dec 2020 10:13:36 +0100 Subject: [PATCH] tests/driver_dac_dds: Report underruns --- tests/driver_dac_dds/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/driver_dac_dds/main.c b/tests/driver_dac_dds/main.c index 3f297a0fb0..949e5917c6 100644 --- a/tests/driver_dac_dds/main.c +++ b/tests/driver_dac_dds/main.c @@ -178,6 +178,9 @@ static void play_function(uint16_t period, uint32_t samples, sample_gen_t fun) /* only work with whole wave periods */ uint16_t len_aligned = DAC_BUF_SIZE - DAC_BUF_SIZE % period; + /* One underrun indication is expected (for the first sample) */ + int underruns = -1; + /* 16 bit samples doubles data rate */ if (res_16b) { samples *= 2; @@ -193,11 +196,15 @@ static void play_function(uint16_t period, uint32_t samples, sample_gen_t fun) size_t len = min(samples, len_aligned); samples -= len; - dac_dds_play(DAC_DDS_CHAN, buf, len); + underruns += !dac_dds_play(DAC_DDS_CHAN, buf, len); /* wait for buffer flip */ mutex_lock(&lock); } + + if (underruns != 0) { + printf("During playback, %d underruns occurred.\n", underruns); + } } #if IS_USED(ENABLE_GREETING)