From 485bd6d9613785d831b13849992d9115a5a4b425 Mon Sep 17 00:00:00 2001 From: Piotr Makaruk Date: Thu, 9 Feb 2023 09:40:11 +0100 Subject: [PATCH] dai: fix xrun handling dai copy should continue with flow if status returns xrun warning Signed-off-by: Piotr Makaruk --- src/audio/dai-zephyr.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index c78d93c56670..bbe0e7aec3dd 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -1226,10 +1226,22 @@ static int dai_copy(struct comp_dev *dev) /* get data sizes from DMA */ ret = dma_get_status(dd->chan->dma->z_dev, dd->chan->index, &stat); - if (ret < 0) { - dai_report_xrun(dev, 0); + switch (ret) { + case 0: + break; + case -EPIPE: + /* DMA status can return -EPIPE and current status content if xrun occurs */ + if (dev->direction == SOF_IPC_STREAM_PLAYBACK) + comp_dbg(dev, "dai_copy(): dma_get_status() underrun occurred, ret = %u", + ret); + else + comp_dbg(dev, "dai_copy(): dma_get_status() overrun occurred, ret = %u", + ret); + break; + default: return ret; } + avail_bytes = stat.pending_length; free_bytes = stat.free;