Mucho tiempo 浪费了这一点 - 我使用 AVAudioPLayer 进行了相当简单的播放,但是当文件播放完毕时,我在调试窗口中收到此消息:
objc [39752]:类 _NSThreadPerformInfo 的对象 0x7304d80 自动释放,没有适当的池 - 只是泄漏 - 在 objc_autoreleaseNoPool() 上中断以进行调试
这是我的播放和回调函数(我已经简化了文件名的创建,但错误是一样的):
@implementation PlaybackEngine {
int _pbIndex;
AVAudioPlayer *_player;
NSArray *fileList;
BufferStores *_BS;
}
....
-(BOOL)startPlayback {
NSURL *playURL = [[NSURL alloc] initWithString:[[DOCUMENTS_FOLDER stringByAppendingPathComponent:@"28Jan13_17:13:21.aif"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
printf("Playback file URL = %s\n", [[playURL path] UTF8String]);
_player = [[AVAudioPlayer alloc] initWithContentsOfURL:playURL error:nil];
_player.delegate = self;
[_player prepareToPlay];
[_player play];
self.playing = YES;
return YES;
}
-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
// check for player stopping due to bad audio data
if (!flag) {
printf("Player finished playing due to bad audio data");
}
self.playing = NO;
_player = nil;
}
我试过设置断点,objc_autoreleaseNoPool
但它永远不会被击中。我犯了什么明显的 ARC 错误?