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

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


The following commit(s) were added to refs/heads/master by this push:
     new c7455e7e8e audio: add offload underflow msg state
c7455e7e8e is described below

commit c7455e7e8e63df696d1cf772ed2ecf05b50420d8
Author: hanqiyuan <hanqiy...@xiaomi.com>
AuthorDate: Tue Feb 27 14:35:20 2024 +0800

    audio: add offload underflow msg state
    
    Signed-off-by: hanqiyuan <hanqiy...@xiaomi.com>
---
 audio/audio.c               | 48 +++++++++++++++++++++++++++++++++++++++++++++
 include/nuttx/audio/audio.h |  1 +
 2 files changed, 49 insertions(+)

diff --git a/audio/audio.c b/audio/audio.c
index e3e1a7dee5..2027c721be 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -834,6 +834,43 @@ static inline void audio_ioerr(FAR struct 
audio_upperhalf_s *upper,
     }
 }
 
+/****************************************************************************
+ * Name: audio_underrun
+ *
+ * Description:
+ *   Send an AUDIO_MSG_UNDERRUN message to the client to indicate that the
+ *   active playback is underrun.  The lower-half driver initiates this
+ *   call via its callback pointer to our upper-half driver.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_AUDIO_MULTI_SESSION
+static inline void audio_underrun(FAR struct audio_upperhalf_s *upper,
+                    FAR struct ap_buffer_s *apb, uint16_t status,
+                    FAR void *session)
+#else
+static inline void audio_underrun(FAR struct audio_upperhalf_s *upper,
+                    FAR struct ap_buffer_s *apb, uint16_t status)
+#endif
+{
+  struct audio_msg_s    msg;
+
+  audinfo("Entry\n");
+
+  /* Send a dequeue message to the user if a message queue is registered */
+
+  if (upper->usermq != NULL)
+    {
+      msg.msg_id = AUDIO_MSG_UNDERRUN;
+      msg.u.ptr = NULL;
+#ifdef CONFIG_AUDIO_MULTI_SESSION
+      msg.session = session;
+#endif
+      file_mq_send(upper->usermq, (FAR const char *)&msg, sizeof(msg),
+                   CONFIG_AUDIO_BUFFER_DEQUEUE_PRIO);
+    }
+}
+
 /****************************************************************************
  * Name: audio_callback
  *
@@ -923,6 +960,17 @@ static void audio_callback(FAR void *handle, uint16_t 
reason,
         }
         break;
 
+      case AUDIO_CALLBACK_UNDERRUN:
+        {
+          /* send underrun status */
+#ifdef CONFIG_AUDIO_MULTI_SESSION
+          audio_underrun(upper, apb, status, session);
+#else
+          audio_underrun(upper, apb, status);
+#endif
+        }
+        break;
+
       default:
         {
           auderr("ERROR: Unknown callback reason code %d\n", reason);
diff --git a/include/nuttx/audio/audio.h b/include/nuttx/audio/audio.h
index 15f69e2ae6..7aba3dc316 100644
--- a/include/nuttx/audio/audio.h
+++ b/include/nuttx/audio/audio.h
@@ -328,6 +328,7 @@
 #define AUDIO_CALLBACK_IOERR        0x02
 #define AUDIO_CALLBACK_COMPLETE     0x03
 #define AUDIO_CALLBACK_MESSAGE      0x04
+#define AUDIO_CALLBACK_UNDERRUN     0x05
 
 /* Audio Pipeline Buffer (AP Buffer) flags **********************************/
 

Reply via email to