【问题标题】:AVAudioEngine inputNode call throws errorAVAudioEngine inputNode 调用抛出错误
【发布时间】:2015-05-14 05:27:28
【问题描述】:

我正在开发一个简单的桌面应用程序,它可以同时播放和录制音频。一切都很顺利,直到我以某种方式解决了一个错误 - 现在每次我尝试调用 AVAudioEngineinputNodemainMixer 时,都会引发错误。

我的标题中有一个属性@property (nonatomic, readonly) AVAudioEngine *engine;,在我的init 方法实现中,下面的代码在inputNode 调用中抛出:

if (self = [super init]) {
   _engine = [[AVAudioEngine alloc] init];

   AVAudioInputNode *node = [_engine inputNode];
}
return self;

在所有异常上设置断点会导致调用堆栈的顶部如下所示:

#0  0x00007fff8ba19ab7 in __cxa_throw ()
#1  0x0000000108123779 in AUHAL::GetAudioChannelLayout(unsigned int, unsigned int, AudioChannelLayout*, unsigned char&) ()
#2  0x00000001081183c6 in AUBase::DispatchGetPropertyInfo(unsigned int, unsigned int, unsigned int, unsigned int&, unsigned char&) ()
#3  0x00000001081cdf66 in AUMethodGetPropertyInfo(void*, unsigned int, unsigned int, unsigned int, unsigned int*, unsigned char*) ()

我之前有这个工作,所以我认为我忘记了一些明显的东西?

【问题讨论】:

    标签: objective-c osx-yosemite avaudioengine


    【解决方案1】:

    好的,所以由于某种原因,删除 All Exceptions 断点解决了这个问题。

    XCode 或 AVFoundation 中存在错误,或者我不知道如何使用 XCode。

    【讨论】:

    • 貌似也是6.3。
    • FWIW,由于抛出的异常是 C++ 异常,如果您仍然想要 Objective-C 异常,可以将“所有异常”断点更改为“所有 Objective-C 异常”(这样做,右键单击“所有异常”断点并选择编辑断点,然后将异常更改为 Objective-C 而不是全部)。
    • 我收到了这个错误,但是删除断点只是意味着我听不到声音:(
    • @ash - 我已经很久没有看过这个了,但也许可以尝试添加 sleep 或做其他事情来阻止程序完成。
    • 谢谢,但事实证明我的问题完全没有关联。似乎使用 AVAudioSource(named:) 加载声音不适用于从 Mac OS 上的资产目录加载声音 - 至少据我所见 - 所以我将声音文件移动到应用程序包中并改用 AVAudioSource(fileNamed:)这解决了问题。如果失败的方法返回 nil 或抛出错误会有所帮助,但代码直到很久以后才变坏,因此很难诊断问题。
    猜你喜欢
    • 2023-04-02
    • 1970-01-01
    • 2018-06-02
    • 1970-01-01
    • 2021-09-04
    • 2018-06-24
    • 2015-11-07
    • 1970-01-01
    • 2017-11-29
    相关资源
    最近更新 更多