iOS上的Opus解码器崩溃没有明显的原因

Tem*_*ema 6 exc-bad-access unity-game-engine ios opus

我有简单的代码将opus帧解码为音频样本.它适用于Android,但它在Unity3D iOS项目中崩溃,并且在常规iOS项目中不会崩溃.

EXC_BAD_ACCESS (code=1, address=0x2f)
Run Code Online (Sandbox Code Playgroud)

两个项目共享相同的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);

}
Run Code Online (Sandbox Code Playgroud)

xcode opus在凯尔特崩溃

堆栈跟踪:

#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
Run Code Online (Sandbox Code Playgroud)

我比较了构建设置并使它们几乎相同.

错误听起来 - 分配有问题.

opus_decoder_create 能够分配OpusDecoder,但错误在于 opus_decode

mar*_*k4o 4

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