AudioQueueStart发布消息以杀死mediaserverd [英] AudioQueueStart posting message to kill mediaserverd

查看:124
本文介绍了AudioQueueStart发布消息以杀死mediaserverd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有钢琴演奏.工作正常,有一点错误.如果我很快同时弹几个键,声音会消失几秒钟,并在控制台中收到以下消息

I have a piano application. It's working fine, with a little error. If I play several keys at the same time very fast, the sounds disappears for a couple of seconds, and receive the following message in the console

AudioQueueStart发布消息以杀死mediaserverd

AudioQueueStart posting message to kill mediaserverd

以下是相关代码:

-(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测试过,并且没有任何内存泄漏.如果有人有想法避免这种错误,将不胜感激.

I have tested with Instruments and I don't have any memory leak. If somebody could have an idea to avoid this error it would be appreciated.

推荐答案

我使用SoundBankPlayer而不是AVAudioPlayer解决"了该问题. SoundBanker信息.

I "solved" the issue using SoundBankPlayer instead of AVAudioPlayer. SoundBanker info.

这篇关于AudioQueueStart发布消息以杀死mediaserverd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆