Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to adjust volume in openSL ES (Android)?

As I read from the official docs for openSL ES, there are capabilities for setting volume level from Audio Player. But how? I tried to get VolumeItf from the audio player but got:

SL_RESULT_FEATURE_UNSUPPORTED

Is I understood, this message means that profiles are not suuported in Android. But how to get access to volume control?

Thanks in advance

like image 972
SirHamlet Avatar asked Jul 19 '11 16:07

SirHamlet


1 Answers

Create AudioPlayer object with IID_VOLUME request. Without doing this, the API returns SL_RESULT_FEATURE_UNSUPPORTED.

const SLInterfaceID ids[2] = {SL_IID_SEEK, SL_IID_VOLUME};
const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};

(*engine)->CreateAudioPlayer(engine, &playerObject, &src, &sink, 2, ids, req);

This workaround is not straightforward but works for me on ndk r6.

like image 119
mootoh Avatar answered Sep 17 '22 23:09

mootoh