开发者

ConvertInput using invalid anchor time error received when recording on device

开发者 https://www.devze.com 2023-02-15 09:13 出处:网络
When creating a recording on an iPhone 4 (4.2.1), I receive the following error in the device console. This error is received immediately after calling the record method. The init of AVAudioRecorder w

When creating a recording on an iPhone 4 (4.2.1), I receive the following error in the device console. This error is received immediately after calling the record method. The init of AVAudioRecorder was successful without error and prepareToRecord returns true.

<AudioQueueServer> aq@0xaf4000: Convert开发者_高级运维Input using invalid anchor time

This error does not happen all the time and does not occur in the simulator.

Here are the audio settings that I am using:

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

Any ideas what this error means?


I found the problem that was causing this error. I'm answering in case anyone else runs into the same issue.

In viewDidLoad of my recorder tab, I set the audio session category to AVAudioSessionCategoryRecord. After recording, my app goes to the playback tab where, in viewDidLoad, the audio session category was reset to AVAudioSessionCategoryPlayback. Upon going back to the recorder tab, the audio session category is still set to AVAudioSessionCategoryPlayback, which causes the error.

To resolve, I set the audio session category to AVAudioSessionCategoryPlayAndRecord in the app delegate.

0

精彩评论

暂无评论...
验证码 换一张
取 消