mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
nuttx/audio: ALLOCATE_BUFFER & BUFFERINFO support multiple calling
support multiple applications simultaneously calling ALLOCATE_BUFFER Signed-off-by: fangyibo <fangyibo@xiaomi.com>
This commit is contained in:
parent
904f391982
commit
b13defe9e4
1 changed files with 40 additions and 0 deletions
|
|
@ -88,6 +88,7 @@ struct audio_upperhalf_s
|
|||
{
|
||||
struct audio_info_s info; /* Record the last playing audio format */
|
||||
mutex_t lock; /* Supports mutual exclusion */
|
||||
uint8_t nbuffers; /* Max ap buffers number */
|
||||
spinlock_t spinlock; /* Supports spin lock */
|
||||
uint8_t periods; /* Ap buffers number */
|
||||
FAR struct ap_buffer_s **apbs; /* Ap buffers list */
|
||||
|
|
@ -767,6 +768,11 @@ static int audio_allocbuffer(FAR struct audio_upperhalf_s *upper,
|
|||
FAR void *newaddr;
|
||||
int ret;
|
||||
|
||||
if (upper->periods >= upper->nbuffers)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bufdesc->u.pbuffer == NULL)
|
||||
{
|
||||
bufdesc->u.pbuffer = &apb;
|
||||
|
|
@ -1180,6 +1186,40 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
}
|
||||
break;
|
||||
|
||||
/* AUDIOIOC_SETBUFFERINFO - Set buffer information
|
||||
*
|
||||
* ioctl argument - pointer to set the buffer information
|
||||
*/
|
||||
|
||||
case AUDIOIOC_SETBUFFERINFO:
|
||||
{
|
||||
audinfo("AUDIOIOC_SETBUFFERINFO\n");
|
||||
|
||||
if (upper->periods == 0)
|
||||
{
|
||||
ret = lower->ops->ioctl(lower, AUDIOIOC_SETBUFFERINFO, arg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* AUDIOIOC_GETBUFFERINFO - Get buffer information
|
||||
*
|
||||
* ioctl argument - pointer to get the buffer information
|
||||
*/
|
||||
|
||||
case AUDIOIOC_GETBUFFERINFO:
|
||||
{
|
||||
audinfo("AUDIOIOC_GETBUFFERINFO\n");
|
||||
|
||||
ret = lower->ops->ioctl(lower, AUDIOIOC_GETBUFFERINFO, arg);
|
||||
if (ret >= 0)
|
||||
{
|
||||
upper->nbuffers =
|
||||
((FAR struct ap_buffer_info_s *)arg)->nbuffers;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Any unrecognized IOCTL commands might be
|
||||
* platform-specific ioctl commands
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue