-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AudioStream.getBufferSizeInFrames() returns 0 on many devices #285
Comments
The ability to set the buffer size dynamically is a new AAudio feature. It helps us achieve lower latency by tuning the buffer size at run time. We cannot implement all of the AAudio features on OpenSL ES but we try. We cannot implement setBufferSizeInFrames(). But I think we could do a better job with getBufferSizeInFrames. I think in this case it might be better to return the fixed buffer size. If our callback buffer is N frames and we have M callback buffers then we could return (N*M). That would be more accurate than zero. |
Thank you. The reason why I asked that is because of the problem mentioned in the issue #286 : on a Galaxy S7, sometimes, the sound is randomly crackled, for a very short period of time when it happens (like a few milliseconds). It really sounds like there is an underrun, so I tried using the AudioStreamBuffered::setBufferSizeInFrames() function to get a bigger buffer. This fix worked like a charm on a device with Android API 27, but unfortunately, it doesn't work on my Galaxy S7 that has API 23 (using OpenSLES, then), since this function is only supported when we are not using a callback (only for OpenSLES). This crackling problem is quite a big issue and I have the problem even with the hello-oboe example. |
I will address the crackling problem in #286 |
Return the BufferCapacityInFrames instead of zero. Fixes #285
Great! Thank you! |
I noticed that, suprisingly, the
AudioStream.getBufferSizeInFrames()
function always returns 0 on many devices, including:Even if I specify a size using
AudioStream.setBufferSizeInFrames()
, it still returns 0, andAudioStream.setBufferSizeInFrames()
returns the following error:oboe::Result::ErrorUnimplemented
Is it a bug, or did I miss something?
How can I set the buffer size if
AudioStream.setBufferSizeInFrames()
doesn't work or is not implemented?EDIT:
I found out that, when I read the Oboe code, I can read, for
AudioStreamBuffered::setBufferSizeInFrames()
(in the OpenSLES section):"Only supported when we are not using a callback"
And the problem is: I use a callback so I can redirect my audio samples on the fly to the audio output.
So, how can I set the buffer size on older versions of Android (< API 27) that use OpenSLES, or, if not possible, how can I play sound without using any callback?
Thanks.
The text was updated successfully, but these errors were encountered: