mirror of
https://github.com/apache/nuttx.git
synced 2026-08-21 21:48:38 +00:00
audio: limit the buffer count guard to shared ring requests
The upper->periods >= upper->nbuffers check sat at the top of audio_allocbuffer(), but upper->periods is only incremented for shared ring requests (u.pbuffer == NULL), so for private buffer callers the check degenerated into "nbuffers == 0" and rejected every allocation when the lower half does not implement AUDIOIOC_GETBUFFERINFO, which is the only place nbuffers is ever assigned. Move the guard inside the shared ring branch so private buffers, which never enter upper->apbs[] and are unrelated to the ring depth, stay allocatable. The zero return value is kept as-is because a second application attaching to the same device relies on it to skip allocation and go straight to AUDIOIOC_ENQUEUEBUFFER. Signed-off-by: fangyibo <fangyibo@xiaomi.com>
This commit is contained in:
parent
5a0ce87654
commit
28e628f0b4
1 changed files with 5 additions and 5 deletions
|
|
@ -769,13 +769,13 @@ 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)
|
||||
{
|
||||
if (upper->periods >= upper->nbuffers)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bufdesc->u.pbuffer = &apb;
|
||||
share = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue