简体   繁体   English

致命错误:AudioKit:无法启动引擎。 调用AudioKit.start()时

[英]Fatal error: AudioKit: Could not start engine. When calling AudioKit.start()

I'm using AudioKit 4.0.4 with iOS 11.2 我在iOS 11.2上使用AudioKit 4.0.4

I'm using a code that is almost the same as the MicrophoneAnalysis sample project. 我使用的代码与MicrophoneAnalysis示例项目几乎相同。

class FrequencyProcessor {

    var node: AKNode {
        return mic
    }

    private let mic: AKMicrophone
    private let tracker: AKFrequencyTracker
    private let silence: AKBooster

    init() {
        AKSettings.audioInputEnabled = true
        mic = AKMicrophone()
        tracker = AKFrequencyTracker(mic)
        silence = AKBooster(tracker, gain: 0)
        AudioKit.output = silence
    }


     func startRecording() {
        AudioKit.start()
     }
}

The code works perfectly in a simulator but I always get this crash when I run it on a device: 该代码在模拟器中可以完美地运行,但是当我在设备上运行它时,我总是会遇到此崩溃:

Fatal error: AudioKit: Could not start engine. error: Error Domain=com.apple.coreaudio.avfaudio Code=-10875 "(null)" UserInfo={failed call=err = AUGraphParser::InitializeActiveNodesInOutputChain(ThisGraph, kOutputChainOptimizedTraversal, *GetOutputNode(), isOutputChainActive)}.

This happens when I call startRecording. 当我调用startRecording时会发生这种情况。

Any idea what may be causing this issue? 任何想法可能导致此问题吗? (I have set the "NSMicrophoneUsageDescription" in Info.plist) (我已经在Info.plist中设置了“ NSMicrophoneUsageDescription”)

edit: The audio recording session happens in a modal view which embeds an AVPlayerLayer. 编辑:音频录制会话在嵌入AVPlayerLayer的模式视图中进行。 If I remove this AVPlayerLayer I no longer have a crash. 如果删除此AVPlayerLayer,我将不再崩溃。 How can I fix this issue? 如何解决此问题?

edit2: I created a sample project here: https://github.com/ydemartino/MicrophoneAnalysisTest.git edit2:我在这里创建了一个示例项目: https : //github.com/ydemartino/MicrophoneAnalysisTest.git

It seems AudioKit doesn't want to work with AVKit: https://github.com/AudioKit/AudioKit/issues/1224 似乎AudioKit不想与AVKit一起使用: https : //github.com/AudioKit/AudioKit/issues/1224

As a workaround, this is what I did: 作为解决方法,这是我所做的:

        let item = videoPlayer.player.currentItem
        videoPlayer.player.replaceCurrentItem(with: nil)
        startAudioKit()
        videoPlayer.player.replaceCurrentItem(with: item)

Not elegant, but at least, it's no longer crashing my app... 不优雅,但至少不会再使我的应用程序崩溃...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM