@@ -88,6 +88,7 @@ struct audio_upperhalf_s
8888{
8989 struct audio_info_s info ; /* Record the last playing audio format */
9090 mutex_t lock ; /* Supports mutual exclusion */
91+ uint8_t nbuffers ; /* Max ap buffers number */
9192 spinlock_t spinlock ; /* Supports spin lock */
9293 uint8_t periods ; /* Ap buffers number */
9394 FAR struct ap_buffer_s * * apbs ; /* Ap buffers list */
@@ -767,6 +768,11 @@ static int audio_allocbuffer(FAR struct audio_upperhalf_s *upper,
767768 FAR void * newaddr ;
768769 int ret ;
769770
771+ if (upper -> periods >= upper -> nbuffers )
772+ {
773+ return 0 ;
774+ }
775+
770776 if (bufdesc -> u .pbuffer == NULL )
771777 {
772778 bufdesc -> u .pbuffer = & apb ;
@@ -1180,6 +1186,40 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
11801186 }
11811187 break ;
11821188
1189+ /* AUDIOIOC_SETBUFFERINFO - Set buffer information
1190+ *
1191+ * ioctl argument - pointer to set the buffer information
1192+ */
1193+
1194+ case AUDIOIOC_SETBUFFERINFO :
1195+ {
1196+ audinfo ("AUDIOIOC_SETBUFFERINFO\n" );
1197+
1198+ if (upper -> periods == 0 )
1199+ {
1200+ ret = lower -> ops -> ioctl (lower , AUDIOIOC_SETBUFFERINFO , arg );
1201+ }
1202+ }
1203+ break ;
1204+
1205+ /* AUDIOIOC_GETBUFFERINFO - Get buffer information
1206+ *
1207+ * ioctl argument - pointer to get the buffer information
1208+ */
1209+
1210+ case AUDIOIOC_GETBUFFERINFO :
1211+ {
1212+ audinfo ("AUDIOIOC_GETBUFFERINFO\n" );
1213+
1214+ ret = lower -> ops -> ioctl (lower , AUDIOIOC_GETBUFFERINFO , arg );
1215+ if (ret >= 0 )
1216+ {
1217+ upper -> nbuffers =
1218+ ((FAR struct ap_buffer_info_s * )arg )-> nbuffers ;
1219+ }
1220+ }
1221+ break ;
1222+
11831223 /* Any unrecognized IOCTL commands might be
11841224 * platform-specific ioctl commands
11851225 */
0 commit comments