@@ -834,6 +834,43 @@ static inline void audio_ioerr(FAR struct audio_upperhalf_s *upper,
834
834
}
835
835
}
836
836
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
+
837
874
/****************************************************************************
838
875
* Name: audio_callback
839
876
*
@@ -923,6 +960,17 @@ static void audio_callback(FAR void *handle, uint16_t reason,
923
960
}
924
961
break ;
925
962
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
+
926
974
default :
927
975
{
928
976
auderr ("ERROR: Unknown callback reason code %d\n" , reason );
0 commit comments