Skip to content

Commit c7455e7

Browse files
qiyuan-hanxiaoxiang781216
authored andcommitted
audio: add offload underflow msg state
Signed-off-by: hanqiyuan <[email protected]>
1 parent 7466237 commit c7455e7

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

audio/audio.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,43 @@ static inline void audio_ioerr(FAR struct audio_upperhalf_s *upper,
834834
}
835835
}
836836

837+
/****************************************************************************
838+
* Name: audio_underrun
839+
*
840+
* Description:
841+
* Send an AUDIO_MSG_UNDERRUN message to the client to indicate that the
842+
* active playback is underrun. The lower-half driver initiates this
843+
* call via its callback pointer to our upper-half driver.
844+
*
845+
****************************************************************************/
846+
847+
#ifdef CONFIG_AUDIO_MULTI_SESSION
848+
static inline void audio_underrun(FAR struct audio_upperhalf_s *upper,
849+
FAR struct ap_buffer_s *apb, uint16_t status,
850+
FAR void *session)
851+
#else
852+
static inline void audio_underrun(FAR struct audio_upperhalf_s *upper,
853+
FAR struct ap_buffer_s *apb, uint16_t status)
854+
#endif
855+
{
856+
struct audio_msg_s msg;
857+
858+
audinfo("Entry\n");
859+
860+
/* Send a dequeue message to the user if a message queue is registered */
861+
862+
if (upper->usermq != NULL)
863+
{
864+
msg.msg_id = AUDIO_MSG_UNDERRUN;
865+
msg.u.ptr = NULL;
866+
#ifdef CONFIG_AUDIO_MULTI_SESSION
867+
msg.session = session;
868+
#endif
869+
file_mq_send(upper->usermq, (FAR const char *)&msg, sizeof(msg),
870+
CONFIG_AUDIO_BUFFER_DEQUEUE_PRIO);
871+
}
872+
}
873+
837874
/****************************************************************************
838875
* Name: audio_callback
839876
*
@@ -923,6 +960,17 @@ static void audio_callback(FAR void *handle, uint16_t reason,
923960
}
924961
break;
925962

963+
case AUDIO_CALLBACK_UNDERRUN:
964+
{
965+
/* send underrun status */
966+
#ifdef CONFIG_AUDIO_MULTI_SESSION
967+
audio_underrun(upper, apb, status, session);
968+
#else
969+
audio_underrun(upper, apb, status);
970+
#endif
971+
}
972+
break;
973+
926974
default:
927975
{
928976
auderr("ERROR: Unknown callback reason code %d\n", reason);

include/nuttx/audio/audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@
328328
#define AUDIO_CALLBACK_IOERR 0x02
329329
#define AUDIO_CALLBACK_COMPLETE 0x03
330330
#define AUDIO_CALLBACK_MESSAGE 0x04
331+
#define AUDIO_CALLBACK_UNDERRUN 0x05
331332

332333
/* Audio Pipeline Buffer (AP Buffer) flags **********************************/
333334

0 commit comments

Comments
 (0)