I have a working OPENSL ES sound engine working on my old project in Eclipse, compiled with android NDK 9. And it works fine there, with that configuration.
When I transfered the project to Android studio, when I try to play any sound it crashes when it tries to CreateAudioPlayer. Other than the sound problem everything works fine.
I am using Android Studio 1.5.1, with with com.android.tools.build:gradle-experimental:0.4.0 plugin and NDK 10 e (latest version).
SLDataLocator_AndroidFD loc_fd = {SL_DATALOCATOR_ANDROIDFD, _FileDescriptor, cache_FileDescriptorStart, cache_FileDescriptorLength};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
audioSrc = {&loc_fd, &format_mime};
// configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject};
SLDataSink audioSnk = {&loc_outmix, NULL};
// create audio player
const SLInterfaceID ids[3] = {SL_IID_SEEK, SL_IID_MUTESOLO, SL_IID_VOLUME};
const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
LOG("Sound: error with %s", _SoundName);
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &uriPlayerObject, &audioSrc,&audioSnk, 3, ids, req);
LOG("playStream end");
It crashes on this line:
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &uriPlayerObject, &audioSrc,&audioSnk, 3, ids, req);
I have checked the file descriptor values, the ids values, every argument that goes into the CreateAudioPlayer function and everything looks fine to me.
LogCat doesn`t give any reasonable message, here is the log:
01-20 20:59:34.705 6256-6287/com.test.full W/google- breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
01-20 20:59:34.706 6256-6287/com.test.full W/google-breakpad: Chrome build fingerprint:
01-20 20:59:34.706 6256-6287/com.test.full W/google-breakpad: 2
01-20 20:59:34.706 6256-6287/com.test.full W/google-breakpad: 869b37da-2f6d-4460-8f9f-e1bd9177efc1
01-20 20:59:34.706 6256-6287/com.test.full W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
01-20 20:59:34.706 6256-6287/com.test.full A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x1 in tid 6287 (GLThread 2240)
As I see it, the problem is in the Android NDK 10, since it is working fine when I compile it with version 9.
Did anyone had this kind of problems ?
Thank you.