Android is supposed to support 3D audio via the OpenSL es API which is accesible via the NDK. That more or less works, I managed it to play sound via a created player and an output mix. But when I try to realise a listener with a 3D location interface (SL_IID_3DLOCATION constant) which is mandatory for playing 3D sound. But when I try to set the constant to SL_BOOLEAN_TRUE the result of the CreateListener method is 12 as passed to the LogCat. 12 is the value of the OpenSL es constant SL_RESULT_FEATURE_UNSUPPORTED. Below you can find a short part of the code, can anyone confirm if I do anything wrong or if the feature really is unsopported, meaning that the OpenSL es implementation does not support 3D audio?
#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C)
const SLInterfaceID listener_ids[] = {SL_IID_3DLOCATION};
const SLboolean listener_req[] = {SL_BOOLEAN_TRUE};
result = (*engine)->CreateListener(engine, &listenerObject, 1, listener_ids, listener_req);
__android_log_print(ANDROID_LOG_VERBOSE, DEBUG_TAG, "CREATE: [%i]", result);
assert(SL_RESULT_SUCCESS == result);
result = (*listenerObject)->Realize(listenerObject, SL_BOOLEAN_FALSE);
__android_log_print(ANDROID_LOG_VERBOSE, DEBUG_TAG, "REALIZE: [%i]", result);
assert(SL_RESULT_SUCCESS == result);
You might want to take a look at this website: https://developer.android.com/ndk/guides/audio/opensl/opensl-for-android. It shows what is and (more importantly), what is not supported by the OpenSL ES API's for Android. I haven't worked with with the 3D location feature, but then again, I haven't had the need for it yet.
Anyway, maybe that site will give you more information about it...
I may have found a solution to this when I had another look at the problem last week. I posted a possible solution with a third party lib here:
Maybe someone who needs it can verify if it worked.
User contributions licensed under CC BY-SA 3.0