AudioQueueStart posting message to kill mediaserverd

*爱你&永不变心* 提交于 2019-12-08 14:08:56

问题


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 posting message to kill mediaserverd

Here is the relevant code:

-(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];
}

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.


回答1:


I suffer from a similar issue.

I spent ages trying to solve the issue, and I think my particular issue takes place when:

  1. I'm in an AudioCategory that doesn't allow sound to play while the mute switch is on.
  2. I start to play a sound (I actually don't do this in the app, but this is how I can reproduce reliably).
  3. With the sound still playing, I switch to another AudioCategory that doesn't allow sound to play while the mute switch is on.

From this point onwards, I get 'posting message to kill mediaserverd' from what looks like various points in calls in the AudioSession API. The app hangs, the device hangs, and I struggle to get the device back to a normal running state.




回答2:


According to this message it's the device's mute switch.

It turns out that having the iPad muted via the device's physical switch was causing the problem with my app. As long as the button is not switched on the problem does not occur.

Sheesh. How to programmatically override?




回答3:


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



来源:https://stackoverflow.com/questions/10952469/audioqueuestart-posting-message-to-kill-mediaserverd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!