[英]AVAudioEngine.connect crash on hardware not simulator
var engine:AVAudioEngine!
var format = engine.inputNode.inputFormat(forBus: 0)
engine.connect(engine.inputNode, to: engine.mainMixerNode, format: format)
在 function AVAudioEngine.connect 使我的应用程序仅在硬件上崩溃,但在模拟器中它很好。
当我在硬件上运行它的错误说。
Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
terminating with uncaught exception of type NSException
我想通了。 我只是将 AVAudioSession 类别类型设置错了。 如果您有同样的错误,请查看 AVAudioSession 并确保您的 AVAudioSession 类别在麦克风权限的正确设置中。 例如
AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with: .mixWithOthers)
使用此设置将允许应用程序同时使用麦克风和播放声音。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.