This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit aba9c292bd16cc03060608da204a7f59f47d8c39
Author: jinxiuxu <[email protected]>
AuthorDate: Mon May 26 11:24:36 2025 +0800

    drivers/virtio-snd: report underrun when latency drops below a period
    
    When a completed buffer reports latency_bytes smaller than one period,
    the device is about to run dry.  Send AUDIO_CALLBACK_UNDERRUN to the
    upper half so it can react instead of glitching silently.
    
    Signed-off-by: jinxiuxu <[email protected]>
---
 drivers/virtio/virtio-snd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/virtio/virtio-snd.c b/drivers/virtio/virtio-snd.c
index ec5f2fcef70..c7cb8b9387c 100644
--- a/drivers/virtio/virtio-snd.c
+++ b/drivers/virtio/virtio-snd.c
@@ -358,6 +358,12 @@ static void virtio_snd_pcm_notify_cb(FAR struct virtqueue 
*vq)
 #endif
       sdev = (FAR struct virtio_snd_dev_s *)buf->dev;
       sdev->cache_buffers--;
+      if (sdev->running &&
+          buf->status->latency_bytes < sdev->period_bytes)
+        {
+          buf->dev->upper(buf->dev->priv, AUDIO_CALLBACK_UNDERRUN,
+                          NULL, OK);
+        }
     }
 }
 

Reply via email to