【发布时间】:2016-04-28 09:15:53
【问题描述】:
我有一个可用的 OPENSL ES 声音引擎,它在 Eclipse 中处理我的旧项目,使用 android NDK 9 编译。它在那里工作正常,使用该配置。
当我将项目转移到 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 编译它时它工作正常。
有人遇到过这种问题吗?
谢谢。
【问题讨论】:
标签: android c++ android-studio android-ndk opensl