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

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

commit 8db9865a030a672de0627fac138f895f112d3783
Author: yangyalei <[email protected]>
AuthorDate: Tue Aug 12 19:37:31 2025 +0800

    nuttx/audio: Add AUDIOIOC_RESETSTATUS ioctl
    
    use AUDIOIOC_RESETSTATUS to reset application pointer
    
    Signed-off-by: yangyalei <[email protected]>
---
 audio/audio.c               | 28 ++++++++++++++++++++++++++++
 include/nuttx/audio/audio.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/audio/audio.c b/audio/audio.c
index 9275a943c0c..c783f9a83f0 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1079,6 +1079,34 @@ static int audio_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
         }
         break;
 
+      /* AUDIOIOC_RESETSTATUS - Reset appl head
+       *
+       *   ioctl argument - pointer to receive the state
+       */
+
+      case AUDIOIOC_RESETSTATUS:
+        {
+          struct audio_buf_desc_s buf_desc;
+          int target;
+
+          buf_desc.numbytes = upper->apbs[0]->nmaxbytes;
+          buf_desc.u.pbuffer = NULL;
+          priv->head = upper->status->head;
+          target = MAX(upper->status->head,
+                       upper->status->tail + upper->periods - 1);
+
+          if (priv->state == AUDIO_STATE_XRUN)
+            {
+              priv->state = AUDIO_STATE_RUNNING;
+            }
+
+          while (priv->head < target)
+            {
+              audio_enqueuebuffer(filep, &buf_desc);
+            }
+        }
+        break;
+
       /* Any unrecognized IOCTL commands might be
        * platform-specific ioctl commands
        */
diff --git a/include/nuttx/audio/audio.h b/include/nuttx/audio/audio.h
index 952c8a282d0..588ecc8c9d3 100644
--- a/include/nuttx/audio/audio.h
+++ b/include/nuttx/audio/audio.h
@@ -119,6 +119,7 @@
 #define AUDIOIOC_GETPOSITION        _AUDIOIOC(21)
 #define AUDIOIOC_GETAUDIOINFO       _AUDIOIOC(22)
 #define AUDIOIOC_GETSTATUS          _AUDIOIOC(23)
+#define AUDIOIOC_RESETSTATUS        _AUDIOIOC(24)
 
 /* Audio Device Types *******************************************************/
 

Reply via email to