2

在 iPhone 4 (4.2.1) 上创建录音时,我在设备控制台中收到以下错误。调用记录方法后立即收到此错误。AVAudioRecorder 的初始化成功且没有错误,prepareToRecord 返回 true。

<AudioQueueServer> aq@0xaf4000: ConvertInput using invalid anchor time

此错误不会一直发生,也不会在模拟器中发生。

以下是我正在使用的音频设置:

    self.recordSetting = [[NSMutableDictionary alloc] init];
    [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
    [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
    [recordSetting setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey];
    [recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVEncoderAudioQualityKey];

任何想法这个错误意味着什么?

4

1 回答 1

4

我找到了导致此错误的问题。我正在回答,以防其他人遇到同样的问题。

在我的录音机选项卡的 viewDidLoad 中,我将音频会话类别设置为 AVAudioSessionCategoryRecord。录制后,我的应用程序转到播放选项卡,在 viewDidLoad 中,音频会话类别被重置为 AVAudioSessionCategoryPlayback。返回到录音机选项卡后,音频会话类别仍设置为 AVAudioSessionCategoryPlayback,这会导致错误。

为了解决这个问题,我在应用程序委托中将音频会话类别设置为 AVAudioSessionCategoryPlayAndRecord。

于 2011-03-21T20:22:44.190 回答