Tuesday, March 22, 2011

[android-developers] What exactly is the obtainBuffer in an AudioTrack?

I wonder, what exactly is the obtainBuffer in an AudioTrack? I ask
this because there is no documentation about it what-so-ever. I have
the famous obtainBuffer timed out (is the CPU pegged?) warning
whenever I try to play a sound in my project, which causes quite a
delay. To try to solve the warning, and minimize the delay, I tried
buffering, placing the write in a separate thread, but this still
didn't solve it. Tinkering with the buffer size in the AudioTrack
didn't work either. It might also be helpful to say that I read a file
from the sd-card in chunks the size of
AudioTrack.getMinBufferSize(...). The total file size varies, as it is
a recording which I record with an AudioRecord, but this works and I
suspect it hasn't got anything to do with it, as it never touches
resources that the AudioTrack might use (at least not in my code).

I've looked at the C++ code which is the AudioTrack's native code, but
I didn't get any wiser there. So I ask you, what exactly is the
obtainBuffer, and how can I prevent (or at least minimize) the delay
when trying to play an audio file?

I've seen enough topics on this issue, but never a decisive answer.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment