我有一个运行正常的OPENSL ES声音引擎,正在使用android NDK 9编译的Eclipse中的旧项目。在该配置下,它在这里工作正常。
当我将项目转移到Android Studio时,当我尝试播放任何声音时,尝试CreateAudioPlayer时会崩溃。 除了声音问题以外,其他所有功能都可以正常工作。
我正在将Android Studio 1.5.1与com.android.tools.build:gradle-experimental:0.4.0插件和NDK 10 R(最新版本)一起使用。
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");
它在此行崩溃:
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &uriPlayerObject, &audioSrc,&audioSnk, 3, ids, req);
我已经检查了文件描述符值,ids值,进入CreateAudioPlayer函数的每个参数,一切对我来说都很好。
LogCat没有给出任何合理的消息,这是日志:
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)
正如我所看到的,问题出在Android NDK 10中,因为当我使用版本9进行编译时,它运行良好。
有人遇到过这类问题吗?
谢谢。