5

I'm trying to figure out some latency issues with the Android AudioTrack, and documentation is very scarce. Two question I have in particular are

  1. Does an AudioTrack object need its buffer full before it starts playing audio, which would indicate that minimum latency one can get in (minimum buffer length) / (sampling rate)? Does it alternatively start playing immediately the first chunk of samples have been given to it? Is there a way to check how full the buffer is before it starts playing?

  2. Secondly, when exactly does AudioTrack block?

Phonon
  • 12,549
  • 13
  • 64
  • 114
  • Some quick experimentation suggests that (1) AudioTrack won't play anything if you don't fill its buffer and (2) AudioTrack.write() starts blocking as soon as the buffer is full. So I am left wondering how to avoid blocking, and how to ensure that all the audio that I want to play gets played -- without unnecessary latency. Yo Google! Write more documentation! Come to think of it, virtually all the APIs could benefit from more documentation. See also http://code.google.com/p/android/issues/detail?id=3434 – Qwertie Jun 02 '12 at 00:18
  • All the on-line examples show the audio writes being executed from a background thread. – Edward Falk Dec 20 '12 at 01:32
  • 2
    @EdwardFalk probably because the writes are blocking – micheal65536 Dec 07 '15 at 13:42

0 Answers0