audio/audio.c: Add message type to support audio trigger.

This commit is contained in:
anchao
2019-11-03 19:52:18 -06:00
committed by Gregory Nutt
parent eb0d0c764e
commit 9e3bafc7c6
2 changed files with 52 additions and 1 deletions
+43
View File
@@ -760,6 +760,39 @@ static inline void audio_complete(FAR struct audio_upperhalf_s *upper,
}
}
/****************************************************************************
* Name: audio_message
*
* Description:
* Send an custom message to the client to indicate that the
* active message has delivered. 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_message(FAR struct audio_upperhalf_s *upper,
FAR struct ap_buffer_s *apb, uint16_t status,
FAR void *session)
#else
static inline void audio_message(FAR struct audio_upperhalf_s *upper,
FAR struct ap_buffer_s *apb, uint16_t status)
#endif
{
struct audio_msg_s *msg = (FAR struct audio_msg_s *)apb;
/* Send a message to the user if a message queue is registered */
if (upper->usermq != NULL)
{
#ifdef CONFIG_AUDIO_MULTI_SESSION
msg.session = session;
#endif
(void)nxmq_send(upper->usermq, (FAR const char *)msg, sizeof(*msg),
CONFIG_AUDIO_BUFFER_DEQUEUE_PRIO);
}
}
/****************************************************************************
* Name: audio_callback
*
@@ -831,6 +864,16 @@ static void audio_callback(FAR void *handle, uint16_t reason,
}
break;
case AUDIO_CALLBACK_MESSAGE:
{
#ifdef CONFIG_AUDIO_MULTI_SESSION
audio_message(upper, apb, status, session);
#else
audio_message(upper, apb, status);
#endif
}
break;
default:
{
auderr("ERROR: Unknown callback reason code %d\n", reason);