피아노 응용 프로그램이 있습니다. 약간의 실수로 문제가 없습니다. 나는 동시에 매우 빠른 여러 개의 키를 재생하면 사운드는 몇 초를 위해 사라지고, 여기AudioQueueStart mediaserverd를 죽일 메시지 게시
가있다 mediaserverd을 죽일
AudioQueueStart 게시 메시지 콘솔에 다음과 같은 메시지가 나타납니다 관련 코드 :
-(IBAction)playNoteFromKeyTouch:(id) sender{ [NSThread detachNewThreadSelector:@selector(playNote:) toTarget:self withObject:[NSString stringWithFormat:@"Piano.mf.%@",[sender currentTitle]]]; } -(void)playNote:(NSString *) note{ NSError *err; NSString *path = [[NSBundle mainBundle] pathForResource:note ofType:@"aiff"]; AVAudioPlayer *p = [[AVAudioPlayer alloc ] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&err]; p.delegate = self; if (err) { NSLog(@"%@", err); }else{ [p prepareToPlay]; [p play]; } } - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { [player release]; }
필자는 Instruments에서 테스트했으며 메모리 누수가 없습니다. 누군가가이 오류를 피할 수있는 아이디어를 가지고 있다면 감사 할 것입니다.
[iphone : mediaserverd를 죽일 수있는 게시 메시지] 가능한 복제본 (http://stackoverflow.com/questions/3762675/iphone-audio-posting-message-to-kill-mediaserverd) –