ios - iOS 上的 Opus 解码器崩溃,原因不明

标签 ios unity3d exc-bad-access opus

我有简单的代码可以将作品帧解码为音频样本。 它适用于 Android,但在 Unity3D iOS 项目中崩溃,在常规 iOS 项目中不会崩溃。

EXC_BAD_ACCESS (code=1, address=0x2f)

两个项目共享相同的 opus 静态库和头文件。

#include "opus.h"

int test1(){
    unsigned char opus_chunk[] = {0x68, 0x97, 0x50, 0x0d,
        0xba, 0xa4, 0x80, 0x0d, 0x31, 0x21, 0x9c, 0xcf, 0x74, 0x98, 0xda, 0xc6,
        0xd5, 0x27, 0xcb, 0xd9, 0x51, 0xd7, 0xce, 0x90, 0xc5, 0x58, 0x94, 0x53,
        0xb0, 0xe9, 0xb4, 0xe4, 0xf4, 0x42, 0x4d, 0xc7, 0xa4, 0x61, 0xfa, 0xfe};
    int len = sizeof(opus_chunk);
    short samples[5760];
    int err1;
    OpusDecoder *decoder;
    decoder = opus_decoder_create(48000, 1, &err1);
    int n = opus_decode(decoder, opus_chunk, len, samples, 5760, 0);
    opus_decoder_destroy(decoder);

}

xcode opus crash in celt

堆栈跟踪:

#0  0x00b944ec in compute_allocation ()
#1  0x00c03698 in celt_decode_with_ec at ./opus_ios/build/src/opus-1.1.2/celt/celt_decoder.c:956
#2  0x00c2400c in opus_decode_frame at ./opus_ios/build/src/opus-1.1.2/src/opus_decoder.c:490
#3  0x00c24ea2 in opus_decode_native [inlined] at ./opus_ios/build/src/opus-1.1.2/src/opus_decoder.c:692
#4  0x00c24e80 in opus_decode at ./opus_ios/build/src/opus-1.1.2/src/opus_decoder.c:782

我比较了build设置并使它们几乎相同。

错误听起来像是 - 分配有问题。

opus_decoder_create 能够分配 OpusDecoder 但错误在 opus_decode

最佳答案

这是由于符号冲突而发生的。 Unity 3D 库定义了一些符号,包括 compute_allocation(),libopus 也定义和使用了这些符号。如果 Unity 3D 库在链接器命令行上位于 libopus 之前,那么它可能会引入该版本,这不适用于 libopus。如果您需要两个集合,那么您可能需要重命名冲突的符号。

关于ios - iOS 上的 Opus 解码器崩溃,原因不明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40402328/

相关文章:

iOS错误: Thread 1:EXC_BAD_ACCESS(code=1,地址=0x726f635f)?

iphone - 如何诊断 KERN_PROTECTION_FAILURE

javascript - react native (RCT_REMAP_METHOD): How to export a method with a parameter and return value?

unity3d - 更新后出现Unity错误

ios - Siri 快捷键在 "Get Contents of URL"POST 中舍入数字

c# - 如何使用带有 IL2CPP 的纯 C++ 代码将 Unity 编译到 Windows 应用程序中?

android - unity : Build failure, 无法更新SDK

ios - 如何确保实例没有被释放?

ios - Xcode 11 调试器非常慢 - 已知问题?

ios - NSDateFormatter 上午/下午没有空格