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:
fangyibo 2026-08-04 14:08:29 +08:00 committed by Xiang Xiao
parent 5a0ce87654
commit 28e628f0b4

View file

@ -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;
}