Alex Darsonik
Alex Darsonik

Reputation: 587

Decoding ogg and other compressed audio file formats with Android SDK (OpenSL)

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.

Upvotes: 1

Views: 1934

Answers (1)

Tamas
Tamas

Reputation: 3442

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.

Upvotes: 2

Related Questions