prustogi / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

Audio renderer situation #576

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The audio renderer for android uses Android MediaPlayer and SoundPool APIs.
There are many known and unfixed issues with those API 
(http://mindtherobot.com/blog/555/android-audio-problems-hidden-limitations-and-
opensl-es/)

One more important issue IMO is that mediaplayer or soundpool cannot be fed 
with inputStream, only fileDescriptors or URL.

So basically the current renderer loads the audio file from the android side. 
This has 2 very bad side effects : 
- The files have to be in the android asset folder in order to be opened, so an 
additional step in the build process has to be done.
- The file is loaded and stored in memory twice : once by the asset manager, 
once by the renderer.

Alternatives : 
- To load an InputStream with MediaPlayer, some write a temporary file to the 
file system then read it back with MP or SP... This is ofc unacceptable
- Some have a web server run in another thread and stream audio over local 
http...wtf?.
- Some use openSL and implement native audio.
http://www.grayfinstudios.com/post?id=ag1ncmF5Zmlud2ViYXBwcgwLEgRQb3N0GIHuBQw
This would imply making a JNI bridge over openSL though, which can be painful.
This is available only for android >2.3 but that's now officially 90% of the 
market.
- Another (cheaper?) alternative could be to fetch the madiaPlayer and sound 
pool native source and just make a setDatabase(inputStream) native interface. 
Not sure it's possible though.
- AudioTrack is another Android API, but it seems to have very restrictive 
unresolved issues (cannot play sounds repeatedly)

Here you can get related information :
http://www.srombauts.fr/android-ndk-r5b/docs/opensles/

http://audioprograming.wordpress.com/2012/03/03/android-audio-streaming-with-ope
nsl-es-and-the-ndk/

http://code.google.com/p/opensl-soundpool/ 
An OpenSl implementaion of soundpool, but cannot be fed with inputStream

Original issue reported on code.google.com by remy.bou...@gmail.com on 13 Feb 2013 at 12:42