gpt4 book ai didi

android - 使用 OpenSL ES 在 Android NDK 中实现 outputMixObject 会导致应用程序崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 06:07:56 24 4
gpt4 key购买 nike

我正在尝试将 OpenSL ES 实现到我的项目中,但在这样做时,我的应用程序崩溃了。当我尝试通过调用它的实现方法来实现 outputMixObject 时发生错误:

// Create OutputMixer.
result = (*engineInstance)->CreateOutputMix(engineInstance, &outputMixObject, 1, NULL, NULL);
assert(result == SL_RESULT_SUCCESS);
// Realize the OutputMixer.
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
assert(result == SL_RESULT_SUCCESS);

当我运行应用程序进行测试时,我得到以下日志条目:

05-11 13:20:19.736: INFO/DEBUG(31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-11 13:20:19.736: INFO/DEBUG(31): Build fingerprint: 'generic/sdk/generic:2.3.1/GSI11/93351:eng/test-keys'
05-11 13:20:19.736: INFO/DEBUG(31): pid: 631, tid: 631 >>> org.test.opensl <<<
05-11 13:20:19.746: INFO/DEBUG(31): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
05-11 13:20:19.746: INFO/DEBUG(31): r0 00000000 r1 00000000 r2 00000000 r3 00000000
05-11 13:20:19.746: INFO/DEBUG(31): r4 82f01bdc r5 8380af69 r6 00000000 r7 418fccc4
05-11 13:20:19.746: INFO/DEBUG(31): r8 bee5f428 r9 418fccbc 10 418fcca4 fp 42596f38
05-11 13:20:19.746: INFO/DEBUG(31): ip 00000000 sp bee5f410 lr 8380af95 pc 82f009ae cpsr 40000030
05-11 13:20:19.986: INFO/DEBUG(31): #00 pc 000009ae /data/data/org.test.opensl/lib/libSLAudio.so
05-11 13:20:19.986: INFO/DEBUG(31): #01 pc 00017d34 /system/lib/libdvm.so
05-11 13:20:19.996: INFO/DEBUG(31): #02 pc 00048ec0 /system/lib/libdvm.so
05-11 13:20:20.007: INFO/DEBUG(31): #03 pc 00041a6a /system/lib/libdvm.so
05-11 13:20:20.007: INFO/DEBUG(31): #04 pc 0004e5dc /system/lib/libdvm.so
05-11 13:20:20.016: INFO/DEBUG(31): #05 pc 0001cf94 /system/lib/libdvm.so
05-11 13:20:20.016: INFO/DEBUG(31): #06 pc 0002209c /system/lib/libdvm.so
05-11 13:20:20.016: INFO/DEBUG(31): #07 pc 00020f90 /system/lib/libdvm.so
05-11 13:20:20.016: INFO/DEBUG(31): #08 pc 0005f50e /system/lib/libdvm.so
05-11 13:20:20.026: INFO/DEBUG(31): #09 pc 00066ed6 /system/lib/libdvm.so
05-11 13:20:20.026: INFO/DEBUG(31): #10 pc 0001cf94 /system/lib/libdvm.so
05-11 13:20:20.057: INFO/DEBUG(31): #11 pc 0002209c /system/lib/libdvm.so
05-11 13:20:20.057: INFO/DEBUG(31): #12 pc 00020f90 /system/lib/libdvm.so
05-11 13:20:20.057: INFO/DEBUG(31): #13 pc 0005f360 /system/lib/libdvm.so
05-11 13:20:20.066: INFO/DEBUG(31): #14 pc 0004b960 /system/lib/libdvm.so
05-11 13:20:20.066: INFO/DEBUG(31): #15 pc 0003eb64 /system/lib/libdvm.so
05-11 13:20:20.066: INFO/DEBUG(31): #16 pc 0003c15c /system/lib/libandroid_runtime.so
05-11 13:20:20.086: INFO/DEBUG(31): #17 pc 0003cf76 /system/lib/libandroid_runtime.so
05-11 13:20:20.086: INFO/DEBUG(31): #18 pc 00008ca2 /system/bin/app_process
05-11 13:20:20.086: INFO/DEBUG(31): #19 pc 00014db8 /system/lib/libc.so
05-11 13:20:20.097: INFO/DEBUG(31): code around pc:
05-11 13:20:20.106: INFO/DEBUG(31): 82f0098c 68116803 32201c22 479868db 1c216a20
05-11 13:20:20.106: INFO/DEBUG(31): 82f0099c 68032201 31189600 230069dd 69a047a8
05-11 13:20:20.106: INFO/DEBUG(31): 82f009ac 68032100 4798681b bd70b002 00001274
05-11 13:20:20.116: INFO/DEBUG(31): 82f009bc 00001228 0000002c 00000002 00000001
05-11 13:20:20.126: INFO/DEBUG(31): 82f009cc 007a1200 00000010 00000010 00000004
05-11 13:20:20.126: INFO/DEBUG(31): code around lr:
05-11 13:20:20.136: INFO/DEBUG(31): 8380af74 29002602 2000d01e 48106008 fcf8f7fd
05-11 13:20:20.136: INFO/DEBUG(31): 8380af84 9300ab05 9a031c39 1c049b0c fa9af7fe
05-11 13:20:20.136: INFO/DEBUG(31): 8380af94 d10f1e06 99051c20 f7fd9a02 1e04fec3
05-11 13:20:20.136: INFO/DEBUG(31): 8380afa4 2603d101 1c20e006 fa30f7fb f0011c20
05-11 13:20:20.136: INFO/DEBUG(31): 8380afb4 602cf8a3 1c30b007 46c0bdf0 00001009
05-11 13:20:20.136: INFO/DEBUG(31): stack:
05-11 13:20:20.136: INFO/DEBUG(31): bee5f3d0 82f01bf4 /data/data/org.test.opensl/lib/libSLAudio.so
05-11 13:20:20.136: INFO/DEBUG(31): bee5f3d4 00000002
05-11 13:20:20.146: INFO/DEBUG(31): bee5f3d8 00000001
05-11 13:20:20.146: INFO/DEBUG(31): bee5f3dc 8380af95 /system/lib/libOpenSLES.so
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3e0 bee5f3f4
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3e4 838089b9 /system/lib/libOpenSLES.so
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3e8 0029cea4 [heap]
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3ec 00000000
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3f0 00000000
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3f4 82f01bfc /data/data/org.test.opensl/lib/libSLAudio.so
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3f8 000001b4
05-11 13:20:20.156: INFO/DEBUG(31): bee5f3fc 82f01bdc /data/data/org.test.opensl/lib/libSLAudio.so
05-11 13:20:20.167: INFO/DEBUG(31): bee5f400 8380af69 /system/lib/libOpenSLES.so
05-11 13:20:20.167: INFO/DEBUG(31): bee5f404 00000000
05-11 13:20:20.167: INFO/DEBUG(31): bee5f408 df002777
05-11 13:20:20.176: INFO/DEBUG(31): bee5f40c e3a070ad
05-11 13:20:20.176: INFO/DEBUG(31): #00 bee5f410 00000000
05-11 13:20:20.176: INFO/DEBUG(31): bee5f414 00000000
05-11 13:20:20.176: INFO/DEBUG(31): bee5f418 bee5f448
05-11 13:20:20.186: INFO/DEBUG(31): bee5f41c 00000000
05-11 13:20:20.186: INFO/DEBUG(31): bee5f420 43d6e7c3 /data/dalvik-cache/data@app@org.test.opensl-2.apk@classes.dex
05-11 13:20:20.186: INFO/DEBUG(31): bee5f424 81d17d38 /system/lib/libdvm.so
05-11 13:20:20.186: INFO/DEBUG(31): #01 bee5f428 41adab28 /dev/ashmem/dalvik-LinearAlloc (deleted)
05-11 13:20:20.186: INFO/DEBUG(31): bee5f42c 0000ce48 [heap]
05-11 13:20:20.186: INFO/DEBUG(31): bee5f430 43d6e7c3 /data/dalvik-cache/data@app@org.test.opensl-2.apk@classes.dex
05-11 13:20:20.186: INFO/DEBUG(31): bee5f434 bee5f508
05-11 13:20:20.186: INFO/DEBUG(31): bee5f438 81d17f00 /system/lib/libdvm.so
05-11 13:20:20.186: INFO/DEBUG(31): bee5f43c 0000ce48 [heap]
05-11 13:20:20.186: INFO/DEBUG(31): bee5f440 bee5f448
05-11 13:20:20.186: INFO/DEBUG(31): bee5f444 81d48ec3 /system/lib/libdvm.so

检查#00 处的程序计数器,表明地址 000009ae 处的方法导致了崩溃。将地址转换为它在我的源文件中出现的行,为我提供了 Realize(outputMixObject, SL_BOOLEAN_FALSE 方法所在的代码行。

请注意,我通过在这个问题上发布的解决方案转换了地址: How to use addr2line in Android

但是,我似乎无法理解它,这可能是由于我对 NDK 或 C/OpenSL ES 总体上缺乏经验......

我在 Android 2.3.1 模拟器上对此进行了测试。前面指定的代码在一个初始化方法中,它为我的应用程序初始化引擎:

JNIEXPORT void JNICALL Java_org_test_opensl_AudioProcessor_createEngine(JNIEnv *env, jobject thiz){
SLresult result;
// Create engine.
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
assert(result == SL_RESULT_SUCCESS);
// Realize the engine.
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
assert(result == SL_RESULT_SUCCESS);
// Get the engine interface, required for the creation of all the other objects.
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineInstance);
assert(result == SL_RESULT_SUCCESS);
// Create OutputMixer.
result = (*engineInstance)->CreateOutputMix(engineInstance, &outputMixObject, 1, NULL, NULL);
assert(result == SL_RESULT_SUCCESS);
// Realize the OutputMixer.
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
assert(result == SL_RESULT_SUCCESS);
}

如果有人能阐明这一点,我们将不胜感激...

最佳答案

result = (*engineInstance)->CreateOutputMix(engineInstance, &outputMixObject, 1, NULL, NULL);

您提供 1 作为 numInterfaces 参数,并为 pInterfaceIds 参数发送 NULL 指针,这将导致在 opensl 内某处的 0x00000000 处出现段错误。

关于android - 使用 OpenSL ES 在 Android NDK 中实现 outputMixObject 会导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5965133/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com