AudioKit 崩溃:所需条件为假:!destNodeMixerConns.empty() && !isDestNodeConnectedToIONode
AudioKit crash: required condition is false: !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
检查 common gotchas video 我看到一个类似的异常被抛出,required condition is false: !nodeMixerConns.empty() && !hasDirectConnToIONode
,这是由于允许变量超出范围而不是保留在 class 中引起的。
所以当我们创建一个 AKPlayer
时会发生这种情况,它保留在 class 中,然后我们用这个播放器创建一个 AKTimePitch
,它也保留在那个 [=28] 中=],最后将其分配给触发异常的 AudioKit.output
。之后,我们将 class 保存在一个数组中的玩家和时间间距上,所以我试图在它创建后将其向上移动,希望这是问题所在,但我看到了同样的异常。
有趣的是,这段代码最初在我们加载第一首歌曲时运行良好,但当我们点击下一首按钮加载下一首歌曲时崩溃。
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 更新,我们没有遇到此崩溃。
我打开了这个项目,看来你对信号链的设置/拆除有点过于放松了。你正在使用局部变量设置 AudioKit 的输出,从不拆除这个信号链,然后回来重置 AudioKit 输出并告诉 AudioKit 开始而不调用 AudioKit.stop()。
我们的项目遇到异常:
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
检查 common gotchas video 我看到一个类似的异常被抛出,required condition is false: !nodeMixerConns.empty() && !hasDirectConnToIONode
,这是由于允许变量超出范围而不是保留在 class 中引起的。
所以当我们创建一个 AKPlayer
时会发生这种情况,它保留在 class 中,然后我们用这个播放器创建一个 AKTimePitch
,它也保留在那个 [=28] 中=],最后将其分配给触发异常的 AudioKit.output
。之后,我们将 class 保存在一个数组中的玩家和时间间距上,所以我试图在它创建后将其向上移动,希望这是问题所在,但我看到了同样的异常。
有趣的是,这段代码最初在我们加载第一首歌曲时运行良好,但当我们点击下一首按钮加载下一首歌曲时崩溃。
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 更新,我们没有遇到此崩溃。
我打开了这个项目,看来你对信号链的设置/拆除有点过于放松了。你正在使用局部变量设置 AudioKit 的输出,从不拆除这个信号链,然后回来重置 AudioKit 输出并告诉 AudioKit 开始而不调用 AudioKit.stop()。