1

Is there a reasonable way to play a memory buffer containing AAC (in an MP4 container) in Android? I cannot write this buffer to disk... it must be played from memory.

Seems that my only option is to decode to PCM manually and use AudioTrack since Android doesn't expose any API that plays non-PCM memory buffers. OpenSL ES has support for memory sources, but Android doesn't implement this.

Fixee
  • 1,581
  • 2
  • 15
  • 25
  • Is there any kind of memory mapped file facility provided by Android's Java? I'm not too familiar with the platform and I am searching around for something like that. If there is such a class, and it returns a FileDescriptor object, then you should be able to pass that to MediaPlayer.setDataSource(). – Multimedia Mike Nov 22 '13 at 08:13
  • Not that I'm aware of. You could use a pipe to obtain a file descriptor (perhaps requiring it be done in native code) but the file descriptor won't be seekable, and therefore wouldn't work properly for the player. – Fixee Nov 22 '13 at 16:50

1 Answers1

0

The only way I can find that does this is (as indicated in my question) to manually decode the AAC. There are a few packages for Android that do this, perhaps ffmpeg is the most well-tested and well-known. ffmpeg can be distilled down to just an AAC decoder so the memory needs are quite small (although it's frustrating to introduce a decoder to a device that already has one natively).

Once AAC is decoded into PCM, it can be played in Java (AudioTrack), or natively (OpenSL ES). The playback latency is notably lower for the native option, if such matters to you.

Fixee
  • 1,581
  • 2
  • 15
  • 25