aaudio: prevent very short sleeps in callback thread

When the buffer size was set to the maximum, the calculation
of the sleep time did not account for the inability to write
ahead of the buffer threshold. So the CPU would wake up,
fail to write, sleep for the minimal time, then repeat.

Now the code checks for the max buffer size.

Bug: b/224871395
Test: see repro steps involving OboeTester in b/224871395#comment19
Test: Use OboeTester, TEST OUTPUT
Test: slide bufferSize fader to far right
Test: look for short sleeps using Perfetto
Change-Id: I2df9e2372c7464ce4f3e8156d7980ec4eadaa2c1
2 files changed