我正在使用AVAudioRecorder錄製音頻,但我正在經歷按鈕按下和開始錄製之間的4秒延遲。AVAudioRecorder記錄4秒滯後
這是我的設置代碼:
NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 16000.0],AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleIMA4],AVFormatIDKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax],AVEncoderAudioQualityKey,nil]; NSError *error = nil; audioRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSettings error:&error]; if (error) { NSLog(@"error: %@", [error localizedDescription]); } else { NSLog(@"prepare to record"); [audioRecorder prepareToRecord]; }
-(void)record {
NSLog(@"Record"); //[audioRecorder prepareToRecord]; if (!audioRecorder.recording) { NSLog(@"Record 2"); [audioRecorder record]; NSLog(@"Record 3"); }
}
記錄被稱爲按下按鈕的功能。我知道prepareToRecord是通過'record'隱式調用的,但我想看看它是否會影響延遲。它不是。
這裏的控制檯日誌:
2011-10-18 21:48:06.508 [2949:707] Record
2011-10-18 21:48:06.509 [2949:707] Record 2
2011-10-18 21:48:10.047 [2949:707] Record 3
有大約3.5秒鐘,這兩點開始錄製之前。
這些設置對於iPhone來說太多了嗎? (iPhone 4)。我初始化它錯了嗎?