AudioKit崩溃:所需条件为假:!destNodeMixerConns.empty()&& !isDestNodeConnectedToIONode [英] AudioKit crash: required condition is false: !destNodeMixerConns.empty() && !isDestNodeConnectedToIONode

查看:152
本文介绍了AudioKit崩溃:所需条件为假:!destNodeMixerConns.empty()&& !isDestNodeConnectedToIONode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目遇到异常:

2019-08-08 10:18:28.703708-0600 AppName[99385:5069475] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: !destNodeMixerConns.empty() && !isDestNodeConnectedToIONode'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010ee2e8db __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x000000010e21bac5 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010ee2e662 +[NSException raise:format:arguments:] + 98
    3   AVFAudio                            0x0000000111b94dbc _Z19AVAE_RaiseExceptionP8NSStringz + 156
    4   AVFAudio                            0x0000000111bf3937 _Z11_AVAE_CheckPKciS0_S0_b + 295
    5   AVFAudio                            0x0000000111b8cb8f _ZN18AVAudioEngineGraph8_ConnectEP19AVAudioNodeImplBaseS1_jjP13AVAudioFormat + 1031
    6   AVFAudio                            0x0000000111bfb598 _ZN17AVAudioEngineImpl7ConnectEP11AVAudioNodeS1_mmP13AVAudioFormat + 194
    7   AVFAudio                            0x0000000111bfb5ff -[AVAudioEngine connect:to:format:] + 83
    8   AppName                             0x000000010a424c10 $s8AudioKitAAC6outputAA6AKNodeCSgvWZTf4dd_n + 2576
    9   AppName                             0x000000010a4230fd $s8AudioKitAAC6outputAA6AKNodeCSgvsZ + 93
    10  AppName                             0x000000010a2ba3a3 $s6AppName7MaestroC17setUpTrackPlayers7fileURLy10Foundation0H0V_tF + 1235

检查常见的陷阱视频,我看到了类似的异常, c0>,这是由于允许变量超出范围而不是保留在类中引起的.

Examining the common gotchas video I see a similar exception being thrown, required condition is false: !nodeMixerConns.empty() && !hasDirectConnToIONode, which is caused by allowing the variables to go out of scope rather than be retained in the class.

因此,当我们创建一个保留在类中的AKPlayer时,会发生这种情况,然后我们使用保留在该类中的该播放器创建一个AKTimePitch,最后将其分配给AudioKit.output,从而触发例外.之后,我们将保存播放器和时间间隔的类存储在一个数组中,因此我希望在创建它之后将其上移,希望是问题所在,但我看到了相同的异常.

So this occurs when we create an AKPlayer, which is retained in a class, then we create an AKTimePitch with this player which is also retained in that class, and finally assign that to AudioKit.output which triggers the exception. After that we were storing the class that holds onto the player and time pitch in an array, so I tried to move this up after it's created in hopes that was the issue, but I see the same exception.

有趣的是,此代码最初在我们加载第一首歌曲时可以正常工作,但是在我们按下"Next"(下一步)按钮以加载下一首歌曲时崩溃.

Interestingly, this code works fine initially when we load up the first song but crashes when we hit the next button to load up the next song.

final class Maestro : NSObject {
    static let shared = Maestro()

    var audioPlayers = [TrackPlayer]()

    func setUpTrackPlayers(fileURL: URL) {
        let playerOne = TrackPlayer(url: fileURL)
        audioPlayers.append(playerOne)

        AudioKit.output = playerOne.handleMixerChain() //boom

        do {
            try AudioKit.start()
        } catch {
            print("Maestro AudioKit.start error: \(error)")
        }
    }

    func next() {
        for player in audioPlayers {
            player.stop()
        }
        audioPlayers.removeAll()

        setUpTrackPlayers(fileURL: newSong.getFileUrl())
    }
}

final class TrackPlayer {
    let player : AKPlayer
    lazy var timePitch = AKTimePitch()

    init(url: URL) {
        player = AKPlayer(url: url)!
    }

    func handleMixerChain(pitch: Double = 0.0, tempo: Double = 1.0) -> AKTimePitch {
        timePitch = AKTimePitch(player)
        timePitch.pitch = pitch
        timePitch.rate = tempo
        return timePitch
    }
}

有什么想法吗?如果您需要更多信息,请告诉我.可能需要注意的是,我们是从AudioKit 4.5.5更新的,我们没有遇到此崩溃.

Any ideas? If you need any more info let me know. May be good to note we are updating from AudioKit 4.5.5 where we didn't experience this crash.

推荐答案

我已经打开了项目,似乎您对信号链的设置/拆除感到太放松了.您正在使用局部变量设置AudioKit的输出,从不拆除此信号链,然后重新设置AudioKit的输出并告诉AudioKit在不调用AudioKit.stop()的情况下启动.

I've opened the project and it seems like you're being a bit too relaxed about your set up / tear down of the signal chain. You're setting up AudioKit's output using local variables, never tearing down this signal chain, and then coming back resetting the AudioKit output and telling AudioKit to start without ever calling AudioKit.stop().

这篇关于AudioKit崩溃:所需条件为假:!destNodeMixerConns.empty()&& !isDestNodeConnectedToIONode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆