1

The documentation of OpenSL, that states "Supported formats include WAV PCM, WAV alaw, WAV ulaw, MP3, Ogg Vorbis, AAC LC, HE-AACv1 (aacPlus), HE-AACv2 (enhanced aacPlus), AMR, and FLAC [provided these are supported by the overall platform, and AAC formats must be located within an MP4 or ADTS container]. MIDI is not supported. WMA is not part of the open source release, and compatibility with Android OpenSL ES has not been verified."

Elsewhere, in forums, I have read that OpenSL on Android doesn't support the decoding of any compressed format. Since the implementation of the decoder using the OpenSL API seems a task that requires at least some hours to be implemented, I would love to understand if I can be sure that once I have put in place all the required boiler-plate code for the decoding I won't find myself with the surprise of not being able to read any compressed format, especially OGG.

1 Answer 1

2

Decoding ogg vorbis with OpenSL works. It even does sampling rate conversion, which is handy. Although I have found that the end of the stream is not signaled with the event SL_PLAYEVENT_HEADATEND. In case of mp3 or wav 'decoding' this event is dispatched. This is not necessary a dealbreaker, b/c you can figure it out that the decoding was finished in other ways.

I eventually added the ogg vorbis sources to my project because I wanted to have more control over the decoding: This way I can tell in advance how long is the decoded clip, for example, but I had to do the sample rate conversion myself.

3
  • 1
    Sure, do you have some money to share? B/c it looks like you have no technical difficulties, but want to outsource this task without spending time on it... (And I don't want to be rude, I'm just asking...)
    – Tamas
    Sep 11, 2014 at 7:38
  • I hoped it was part of a public project. I need to say that for such time consuming, annoying tasks that aren't really original programming ideas but can eventually be considered all boilerplate code, I am always up to share. for example creating a Gist. Sep 11, 2014 at 8:06
  • 1
    If you want to use OpnenSL, look at the native-audio example project in android-ndk. (Wheteher the played audio is a wav file or ogg, doesn't matter.) And you have to change the player's sink to a buffer queue, similar to the recorder example in the same project. If you want to include ogg/vorbis sources to your project look at how libgdx does. (Or just use libgdx instead)
    – Tamas
    Sep 11, 2014 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.