Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecorderObject in OpenSL does not implement the interface to set the volume or configure on Android

Tags:

android

opensl

I tried to get the SLDeviceVolumeItf interface of the RecorderObject on Android but I got the error: SL_RESULT_FEATURE_UNSUPPORTED.

I read that the Android implementation of OpenSL ES does not support volume setting for the AudioRecorder. Is that true?

If yes is there a workaround? I have a VOIP application that does not worl well on Galaxy Nexus because of the very high mic gain.

I also tried to get the SL_IID_ANDROIDCONFIGURATION to set the streamType to the new VOICE_COMMUNINCATION audio-source but again I get error 12 (not supported).

   // create audio recorder
const SLInterfaceID id[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION };
const SLboolean    req[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };

result = (*engine)->CreateAudioRecorder(engine, &recorderObject, &audioSrc,  &audioSnk, 2, id, req);
if (SL_RESULT_SUCCESS != result) {
    return false;
}

SLAndroidConfigurationItf recorderConfig;   
result = (*recorderObject)->GetInterface(recorderObject, SL_IID_ANDROIDCONFIGURATION, &recorderConfig);
if(result != SL_RESULT_SUCCESS) {
    error("failed to get SL_IID_ANDROIDCONFIGURATION interface. e == %d", result);
}

The recorderObject is created but I can't get the SL_IID_ANDROIDCONFIGURATION interface. I tried it on Galaxy Nexus (ICS), HTC sense (ICS) and Motorola Blur (Gingerbread). I'm using NDK version 6.

like image 903
kingston Avatar asked Nov 13 '22 04:11

kingston


1 Answers

Now I can get the interface. I had to use NDK 8 and target-14. When I tried to use 10 as a target, I had an error compiling the native code (dirent.h was not found). I had to use target-platform-14.

like image 125
kingston Avatar answered Nov 16 '22 03:11

kingston