【发布时间】:2017-01-25 08:48:51
【问题描述】:
我有一个带有非常基本的音频组件的应用程序:一组循环播放的背景歌曲,使用 AVAudioPlayer(歌曲文件名存储为数组)。几个月来一切都运行良好,但 iOS 10 对我的大量用户(每天数千)崩溃了。
问题是,我无法弄清楚 iOS 10 中发生了什么变化。似乎每次用户锁定他们的设备时都会发生这种情况,特别是在音乐结束淡出的那一刻发生(它不做背景音频,因此离开应用程序会自动淡出音乐)。
那一刻,我每次都得到这个:
2016-09-22 17:06:39.439979 TerraGenesis[8533:2459778] [aurioc] 889: failed: '!pla' (enable 2, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
2016-09-22 17:06:39.443348 TerraGenesis[8533:2459778] [aurioc] 889: failed: '!pla' (enable 2, outf< 2 ch, 44100 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
2016-09-22 17:06:39.445339 TerraGenesis[8533:2459778] [central] 54: ERROR: [0x1b50d6c40] >avae> AVAudioEngineGraph.mm:2515: PerformCommand: error 561015905
2016-09-22 17:06:39.446646 TerraGenesis[8533:2459778] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error 561015905'
*** First throw call stack:
(0x1904781c0 0x18eeb055c 0x190478094 0x1a99d978c 0x1a99ed170 0x1a99ede58 0x1a9a5b3a0 0x1a9a5a6b0 0x1a9a5a640 0x1a0228580 0x1a020cff8 0x19041222c 0x190411930 0x1904116ac 0x190480b9c 0x190353bf4 0x190e5a6bc 0x1963284a0 0x19654df40 0x19655c3ec 0x196547ae8 0x19654776c 0x196879034 0x191febbd4 0x192019904 0x192019770 0x192019b18 0x190426278 0x190425bc0 0x1904237c0 0x190352048 0x191dd5198 0x19632b818 0x196326550 0x1001c1428 0x18f3345b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
这是堆栈跟踪:
Fatal Exception: com.apple.coreaudio.avfaudio
0 CoreFoundation 0x18d45c1c0 __exceptionPreprocess
1 libobjc.A.dylib 0x18be9455c objc_exception_throw
2 CoreFoundation 0x18d45c094 +[NSException raise:format:]
3 AVFAudio 0x1a6a7578c AVAE_RaiseException(NSString*, ...)
4 AVFAudio 0x1a6a89170 AVAudioEngineGraph::PerformCommand(AUGraphNode&, AVAudioEngineGraph::ENodeCommand, void*, unsigned int) const
5 AVFAudio 0x1a6a89e58 AVAudioEngineGraph::Initialize()
6 AVFAudio 0x1a6af73a0 AVAudioEngineImpl::Initialize()
7 AVFAudio 0x1a6af66b0 AVAudioEngineImpl::Start(NSError**)
8 AVFAudio 0x1a6af6640 -[AVAudioEngine startAndReturnError:]
9 SceneKit 0x19d20c580 CPP3DAudioEngine::GetAVEngine()
10 SceneKit 0x19d1f0ff8 -[SCNView _enterBackground:]
这是我的代码。这是我的代码中唯一以任何方式处理音频的部分。
-(void)playNextSong {
int musicPlaybackIndex = [[[NSUserDefaults standardUserDefaults] objectForKey:@"musicPlaybackIndex"] intValue];
NSURL *soundFileURL = [NSURL fileURLWithPath:[_musicPlaylist objectAtIndex:musicPlaybackIndex]];
_musicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
_musicPlayer.volume = 0.15;
_musicPlayer.delegate = self;
[_musicPlayer prepareToPlay];
[_musicPlayer play];
if(musicPlaybackIndex+1 < [_musicPlaylist count]) {
musicPlaybackIndex++;
} else {
musicPlaybackIndex = 0;
}
}
我在 iPhone、iPad 和 iPod touch 上看到了这种崩溃,但仅限于 iOS 10.0.0 和 10.0.1。我一直在寻找那些“[aurioc]”调用几个小时,但我找不到任何有用的东西,而且它是用我无法完全解析的行话写的。
谁能告诉我我可能做错了什么,或者帮助我指出 iOS 10 中的 AVAudioPlayer 可能发生的变化?
【问题讨论】:
标签: ios objective-c avfoundation avaudioplayer ios10