audio: add offload underflow msg state

Signed-off-by: hanqiyuan <hanqiyuan@xiaomi.com>
This commit is contained in:
hanqiyuan 2024-02-27 14:35:20 +08:00 committed by Xiang Xiao
parent 7466237b14
commit c7455e7e8e
2 changed files with 49 additions and 0 deletions

View file

@ -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);

View file

@ -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 **********************************/