【问题标题】:Opus decoder on iOS is crashing with no obvious reasoniOS 上的 Opus 解码器在没有明显原因的情况下崩溃
【发布时间】:2016-11-20 06:20:54
【问题描述】:

我有将作品帧解码为音频样本的简单代码。 它可以在 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);

}

堆栈跟踪:

#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

我比较了构建设置并使其几乎相同。

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

opus_decoder_create 能够分配 OpusDecoder 但错误在opus_decode

【问题讨论】:

    标签: ios unity3d exc-bad-access opus


    【解决方案1】:

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

    【讨论】:

    • 很高兴您在这里回复!再次感谢。
    • 是否有任何替代解决方案(例如,将编译器配置为删除除某些名称之外的所有名称)?每当 Unity 引入新的内部函数名称时,此解决方案都可能会中断。
    猜你喜欢
    • 1970-01-01
    • 2015-12-08
    • 2014-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多